MultiRow Windows Forms > Developer's Guide > Using MultiRow > Cell Styles > User-defined Word Wrap |
In MultiRow, you can customize the word wrapping position of the content in the cell, by recognizing a specified number of characters, or double byte numbers, as one word.
You can customize the behavior of word wrap, by creating a class that implements the ICustomWordWrapProvider interface.
The following code creates a class that implements the ICustomWordWrapProvider interface, which specifies the word wrap position by number of characters.
Imports GrapeCity.Win.MultiRow Public Class MyWordWrap Implements ICustomWordWrapProvider Public Function GetWordUnits(text As String) As System.Collections.Generic.IEnumerable(Of WordWrapUnit) Implements ICustomWordWrapProvider.GetWordUnits Dim list As New List(Of WordWrapUnit)() If text = "abcde,fghij" Then list.Add(New WordWrapUnit(0, 3)) list.Add(New WordWrapUnit(3, 8)) End If Return list End Function End Class |
using GrapeCity.Win.MultiRow; public class MyWordWrap : ICustomWordWrapProvider { public IEnumerable<WordWrapUnit> GetWordUnits(string text) { List<WordWrapUnit> list = new List<WordWrapUnit>(); if (text == "abcde,fghij") { list.Add(new WordWrapUnit(0, 3)); list.Add(new WordWrapUnit(3, 8)); } return list; } } |
Set the CellStyle.CustomWordWrapProvider property to the class that implements the ICustomWordWrapProvider interface.
You need to perform the following steps to enable this feature.
GcMultiRow1(0, 0).Style.UseCompatibleTextRendering = MultiRowTriState.True GcMultiRow1(0, 0).Style.WordWrap = MultiRowTriState.True GcMultiRow1(0, 0).Style.Multiline = MultiRowTriState.True GcMultiRow1(0, 0).Style.CustomWordWrapProvider = New MyWordWrap() |
gcMultiRow1[0, 0].Style.UseCompatibleTextRendering = MultiRowTriState.True; gcMultiRow1[0, 0].Style.WordWrap = MultiRowTriState.True; gcMultiRow1[0, 0].Style.Multiline = MultiRowTriState.True; gcMultiRow1[0, 0].Style.CustomWordWrapProvider = new MyWordWrap(); |