The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I''m using a GridDataBoundGrid which have columns which cellType is Currency. I need to limit the amount or the number of characters. I have tried e.Style.MaxLength = 15 at Model_QueryCellInfo event (it works for other types of cells) but it doesn''t work. How can i set the maxlength of the column?
ADAdministrator Syncfusion Team September 12, 2006 03:36 AM UTC
Hi Borja,
The GridStyleInfo.MaxLength properly is only used with the TextBox cell type.
For Currency celltypes, you would have to set the GridStyleInfo.CurrecyEdit.CurrencyDecimalDigits and the GridStyleInfo.CurrecyEdit.CurrencyNumberDigits properties of the cell. The CurrencyDecimalDigits sets the maximum number of digits for the decimal portion of the currency. The CurrencyNumberDigits set the number of digits for the number part. Below is a code snippet.
For other cell types, you would have to handle things yourself. A straight-forward way of doing this is to handle the CurrentCellKeyPress event and set e.Handled if the current string is to long. Below is a code.
Private Sub GridDataBoundGrid1_CurrentCellKeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs) Handles GridDataBoundGrid1.CurrentCellKeyPress Dim cc As GridCurrentCell = Me.GridDataBoundGrid1.CurrentCell If cc.Renderer.ControlText.Length >= Me.GridDataBoundGrid1(cc.RowIndex, cc.ColIndex).MaxLength Then e.Handled = True End If End Sub
Let me know if something like this will not work for you.