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.

CurrencyCell and Behavior of "." && - keys

Thread ID:

Created:

Updated:

Platform:

Replies:

79686 Feb 20,2009 11:15 AM Feb 25,2009 05:42 AM Windows Forms 4
loading
Tags: GridControl
Sameer Khan
Asked On February 20, 2009 11:15 AM

In a GGC I have a RecordFieldCell's cell type configured as a "Currency".

This is pretty useful, the problem I am having though is that when the user hits the "." Key or "-" key with the cell text selected, I want to underlying cell value to be cleared off; This is what would have happened Had I not used a currency cell.

Is there a way to get this behavior back?

I have the following properties set on the Apeearance of my numeric columns.


AnyRecordFieldCell.StrictValueType = true;
AnyRecordFieldCell.CellType = "Currency";
AnyRecordFieldCell.CurrencyEdit.CurrencyDecimalDigits = 2;
AnyRecordFieldCell.CurrencyEdit.CurrencyGroupSeparator = ",";
AnyRecordFieldCell.CurrencyEdit.CurrencyNegativePattern = 1;
AnyRecordFieldCell.CurrencyEdit.CurrencyPositivePattern = 0;
AnyRecordFieldCell.CurrencyEdit.NegativeSign = "-";
AnyRecordFieldCell.CurrencyEdit.CurrencySymbol = string.Empty;




Jisha Joy [Syncfusion]
Replied On February 23, 2009 02:17 AM


Hi Sameer,


Please try handling the following code and let me know if this helps.

this.gridGroupingControl1.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CurrencyEdit.NullString = String.Empty;

Regards,
Jisha


Sameer Khan
Replied On February 23, 2009 08:59 AM

No, this does not work; also this has nothing to do with my question.

I will try and rephrase it.

I want the Currency Cell Feature. But I also want the Currency Cell to behave like a regular textbox [maybe] as in ->

If there is a number say 20.0 .. for the currency box, if I select the text and hit "."; the caret is immediately moved after the "." ; I dont want that when the user hits '.' I want the cell to have 0 value.

Similarly "-" sign toggles the value for currency, but If the text is selected; I would like the "-" to stay ,, and nothing else.

--------------------------------
If this helps ->
--------------------------------
I had attempted to use a class derived from GridGenericControlCellRenderer which hosted a DoubleTextBox and I had to customize the DoubleTextBox by overriding the HandleSubtractKey and HandleDecimalKey.
In addition I had to set the following properties:

NegativeInputPendingOnSelectAll = true;
DeleteSelectionOnNegative = true;

protected override NumberModifyState HandleSubtractKey()
{
if (NegativeSign == "-" && SelectionLength > 0)
{
Text = "-0.00";
}


return base.HandleSubtractKey();
}


protected override bool HandleDecimalKey()
{
if (DeleteOnDecimal)
{
if (SelectionLength > 0)
{
Clear();
}
}
return base.HandleDecimalKey();
}


>
Hi Sameer,


Please try handling the following code and let me know if this helps.

this.gridGroupingControl1.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CurrencyEdit.NullString = String.Empty;

Regards,
Jisha




Sameer Khan
Replied On February 24, 2009 08:52 AM

Is there a fix for this?

-S

>No, this does not work; also this has nothing to do with my question.

I will try and rephrase it.

I want the Currency Cell Feature. But I also want the Currency Cell to behave like a regular textbox [maybe] as in ->

If there is a number say 20.0 .. for the currency box, if I select the text and hit "."; the caret is immediately moved after the "." ; I dont want that when the user hits '.' I want the cell to have 0 value.

Similarly "-" sign toggles the value for currency, but If the text is selected; I would like the "-" to stay ,, and nothing else.

--------------------------------
If this helps ->
--------------------------------
I had attempted to use a class derived from GridGenericControlCellRenderer which hosted a DoubleTextBox and I had to customize the DoubleTextBox by overriding the HandleSubtractKey and HandleDecimalKey.
In addition I had to set the following properties:

NegativeInputPendingOnSelectAll = true;
DeleteSelectionOnNegative = true;

protected override NumberModifyState HandleSubtractKey()
{
if (NegativeSign == "-" && SelectionLength > 0)
{
Text = "-0.00";
}


return base.HandleSubtractKey();
}


protected override bool HandleDecimalKey()
{
if (DeleteOnDecimal)
{
if (SelectionLength > 0)
{
Clear();
}
}
return base.HandleDecimalKey();
}


>
Hi Sameer,


Please try handling the following code and let me know if this helps.

this.gridGroupingControl1.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CurrencyEdit.NullString = String.Empty;

Regards,
Jisha






Jisha Joy [Syncfusion]
Replied On February 25, 2009 05:42 AM

Hi Sameer,

You can do this dynamically in DrawCellDisplayText event. This way you do not modify the actual datatable values, but instead just change what the grid displays. In that event you need to set the e.DisplayText to some new value to want to display. Use the e.RowIndex and e.ColIndex to get the row and column of the cell for which the displaytext has to be set. Also you can get StyleInformation of the gridcell using e.Style property. Below are the codes.

void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
double d;
if (e.Inner.Style.CellType == "Currency" && e.Inner.Style.CellValue!=null) // could also check e.Style.CellIdentity.RowIndex/ColIndex
{
if (double.TryParse(e.Inner.Style.CellValue.ToString(), System.Globalization.NumberStyles.Any, null, out d)
&& d == 0)
{
e.Inner.DisplayText = "0";

}
}
}


Please let me know if this helps.

Regards,
Jisha


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.

;