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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Handling Negative Values in Bounded Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

52058 Nov 21,2006 10:43 AM UTC Nov 21,2006 12:53 PM UTC WinForms 3
loading
Tags: GridControl
Lokesh
Asked On November 21, 2006 10:43 AM UTC

Hello
I have a bounded grid . The Cell type is Currency . I have writtem the code as

Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CellType = "Currency"
Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CurrencyEdit.CurrencyNumberDigits = 3
Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CurrencyEdit.CurrencyDecimalDigits = 1
Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CurrencyEdit.CurrencySymbol = ""
Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CurrencyEdit.NullString = ""
The problem is If i put a Negative value then in that case the cell text gets RED . Is there any way I can restric the user to put negative values . I hope I have made u understand the problem .

Regards
Lokesh

Administrator [Syncfusion]
Replied On November 21, 2006 11:20 AM UTC

Hi Lokesh,

The following code states how to set the NegativeSign, NegativeColor and CurrencyNegativePattern of the currency cell in a grid. Please try this and let me know if you are looking something different.

Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CurrencyEdit.NegativeColor = Color.Black
Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CurrencyEdit.NegativeSign = string.Empty;
Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CurrencyEdit.CurrencyNegativePattern = 1;

Best Regards,
Haneef

Lokesh
Replied On November 21, 2006 12:05 PM UTC

Hello Haneef
Thanks for the Answer but I dont want the user to put any negative values . That means my grid cell should accept only positive values .

regards
lokesh


>Hi Lokesh,

The following code states how to set the NegativeSign, NegativeColor and CurrencyNegativePattern of the currency cell in a grid. Please try this and let me know if you are looking something different.

Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CurrencyEdit.NegativeColor = Color.Black
Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CurrencyEdit.NegativeSign = string.Empty;
Qualification.GridBoundColumns(GridColumns.ScheduledHours).StyleInfo.CurrencyEdit.CurrencyNegativePattern = 1;

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On November 21, 2006 12:53 PM UTC

Hi Lokesh,

You can acess the GridCurrencyTextBox control and handle the CurrencyTextBox.KeyValidate event to cancel the '-' key in a currency cell. Here is a code snippet to show this.

private void gridDataBoundGrid1_CurrentCellControlGotFocus(object sender, ControlEventArgs e)
{
GridCurrencyTextBox cCurrencyTextBox = e.Control as GridCurrencyTextBox;
if( cCurrencyTextBox != null)
cCurrencyTextBox.KeyValidate +=new KeyValidateEventHandler(cCurrencyTextBox_KeyValidate);
}
private void cCurrencyTextBox_KeyValidate(object sender, KeyValidateEventArgs e)
{
if( e.Key == '-')
e.Cancel = true;
}

Best Regards,
Haneef

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.

Warning Icon 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.Close Icon

;