MultiRow Windows Forms > Developer's Guide > Using MultiRow > Cell Styles > 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.
Create a class that implements the ITextAdjustmentProvider interface, to uniformly display single-byte characters in a cell.
This example creates a class to uniformly display single-byte characters in a cell.
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 |
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; } } |
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.
This example sets the justification using the created class.
GcMultiRow1(0, 0).Style.UseCompatibleTextRendering = MultiRowTriState.True GcMultiRow1(0, 0).Style.TextAdjustment = TextAdjustment.DistributeWithSpace GcMultiRow1(0, 0).Style.TextAdjustmentProvider = New DistributeEveryChar() |
gcMultiRow1[0, 0].Style.UseCompatibleTextRendering = MultiRowTriState.True; gcMultiRow1[0, 0].Style.TextAdjustment = TextAdjustment.DistributeWithSpace; gcMultiRow1[0, 0].Style.TextAdjustmentProvider = new DistributeEveryChar(); |