AD
Administrator
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 column 2:
this.grid.ColStyle[2].CurrencyEdit.CurrencyDecimalDigits = 0;
this.grid.ColStyle[2].CurrencyEdit.CurrencyNumberDigits = 5;
//QueryCellInfo event cell.
e.Style.CurrencyEdit.CurrencyDecimalDigits = 0;
e.Style.CurrencyEdit.CurrencyNumberDigits = 5;
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.
Regards,
Haneef
BO
Borja
September 12, 2006 07:08 AM UTC
It worked fine, thank you.