We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Limit currency cell''s maxlength at GDBG

Thread ID:

Created:

Updated:

Platform:

Replies:

49103 Sep 11,2006 12:47 PM Sep 12,2006 03:08 AM Windows Forms 2
loading
Tags: GridControl
Borja
Asked On September 11, 2006 12:47 PM

Hi,

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?

Thank you
Borja

Administrator [Syncfusion]
Replied On September 11, 2006 11:36 PM

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

Borja
Replied On September 12, 2006 03:08 AM

It worked fine, thank you.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;