GrapeCity MultiRow Windows Forms Documentation
Customizing the Justification of Single-byte Characters

By default, if you use justification in single-byte characters, the spaces are expanded, but if you use the ITextAdjustmentProvider interface, you can uniformly display single-byte characters in a cell.

Justification of Single-byte Characters

Customizing the Justification

Create a class that implements the ITextAdjustmentProvider interface, to uniformly display single-byte characters in a cell.

Using Code

This example creates a class to uniformly display single-byte characters in a cell.

[VB]

Imports GrapeCity.Win.MultiRow 
Public Class DistributeEveryChar Implements ITextAdjustmentProvider 
Public Function GetTextElements(text As String) As System.Collections.Generic.IEnumerable(Of String) Implements ITextAdjustmentProvider.GetTextElements 
Dim textElements As New List(Of String)() 
For i As Integer = 0 To text.Length - 1 
textElements.Add(text(i).ToString()) 
Next 
Return textElements 
End Function 
End Class

[CS]

using GrapeCity.Win.MultiRow; 
public class DistributeEveryChar : ITextAdjustmentProvider 
{ 
public IEnumerable& GetTextElements(string text) 
{
List <string> textElements = new List<string&>(); 
for (int i = 0; i < text.Length; i++) {
textElements.Add(text[i].ToString()); 
} 
return textElements; 
} 
}

Setting the Justification

Set the CellStyle.TextAdjustmentProvider property to the class that implements the ITextAdjustmentProvider interface (the class that was created for the customization of justification settings).

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

Using Code

This example sets the justification using the created class.

[VB]

GcMultiRow1(0, 0).Style.UseCompatibleTextRendering = MultiRowTriState.True 
GcMultiRow1(0, 0).Style.TextAdjustment = TextAdjustment.DistributeWithSpace 
GcMultiRow1(0, 0).Style.TextAdjustmentProvider = New DistributeEveryChar()

[CS]

gcMultiRow1[0, 0].Style.UseCompatibleTextRendering = MultiRowTriState.True; 
gcMultiRow1[0, 0].Style.TextAdjustment = TextAdjustment.DistributeWithSpace;
gcMultiRow1[0, 0].Style.TextAdjustmentProvider = new DistributeEveryChar();
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options