GrapeCity MultiRow Windows Forms Documentation
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.

Word Wrap by Number of Characters

Word Wrap by Number of Characters

Using Code

The following code creates a class that implements the ICustomWordWrapProvider interface, which specifies the word wrap position by number of characters.

[VB]

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

[CS]

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.

Using Code

You need to perform the following steps to enable this feature.

[VB]

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()

[CS]

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();
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options