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;
JJ
Jisha Joy
Syncfusion Team
February 23, 2009 07:17 AM UTC
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
SK
Sameer Khan
February 23, 2009 01:59 PM UTC
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
SK
Sameer Khan
February 24, 2009 01:52 PM UTC
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
JJ
Jisha Joy
Syncfusion Team
February 25, 2009 10:42 AM UTC
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