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. Image for the cookie policy date

GridControl nullable currency edit

Hello, I have three questions regarding WPF GridControl and CurrencyEdit cell type:

1. How can I create a nullable currency cell? After I set CurrencyEdit cell type, all cells are displayed as 0,00 $, except if I explicitly reset all cells to null.

2. When I edit a currency cell I have found no way to set it to null. If I try to delete contents it just displays 0,00 instead of empty text.

3. When editing a cell, how can I force up / down arrow keys to leave cell and move up or down instead of increasing / decreasing cell value?

Thanks in advance.

3 Replies

PS Pannir Selvam S Syncfusion Team April 2, 2013 05:20 PM UTC

Hi De,

 

Thanks for choosing Syncfusion Product.

 

Query

Comments

How can I create a nullable currency cell? After I set CurrencyEdit cell type, all cells are displayed as 0,00 $, except if I explicitly reset all cells to null.

You can set the value as null by assigning the CellValue as null like in below code snippet.

 

this.grid.Model[1, 1].CellValue = null;

 

When I edit a currency cell I have found no way to set it to null. If I try to delete contents it just displays 0,00 instead of empty text.

You can achieve this requirement by handling the CommitCellInfo event of grid and set the cellvalue as null when the value is zero.

When editing a cell, how can I force up / down arrow keys to leave cell and move up or down instead of increasing / decreasing cell value?

You can achieve this by handling the CurrentCellPreviewKeyDown event of GridControl.

 

We have attached a sample based on the above requirement for your reference.

 

Please let us know if you have any other queries.

 

Regards,

Pannir.



GC_Basic Sample_f075c96d.zip


DE DE April 3, 2013 04:53 PM UTC

Thank you for your reply. However, it does not solve my problem.

First question is no big deal as it has a workaround and you have proposed the same solution as I have mentioned in my question: to explicitly set all cell values to null.

Second question is still not solved. Your suggestion is to convert 0 to null after cell has been edited. However, 0 is a valid value and null means the cell is empty, so there has to be a distinction between these two.

I think there is a bug in you source code.

In GridCellCurrencyEditCellRenderer.OnCurrencyValueChanged I have found the following code:
if (!uiElement.Value.HasValue) { uiElement.Value = 0; }

If I set breakpoint here I can see that the CurrencyTextBox.Value is first correctly set to null and then changed to zero. I don't think this is correct behavior. The code should at least check if UseNullOption flag is set or not. Do you have any suggestion how to work around this behavior as the method is private and cannot be overridden?

For the third question I have found a better method to just set
Style.CurrencyEdit.IsScrollingOnCircle = false;

Thank you.


PS Pannir Selvam S Syncfusion Team April 10, 2013 04:12 AM UTC

Hi De,

 

We have analyzed your query and Please find the below response.

 

Regarding Query#1,

If you want to display the CurrencyEdit cell as empty or null, then you need to explicitly set the Cellvalue as null and also set UseNullOption as true like in the below code snippet.

 

Code Snippet[C#]:

   this.grid.Model[1, 1].CellType = "CurrencyEdit";

   this.grid.Model[1, 1].CurrencyEdit.UseNullOption = true;

   this.grid.Model[1, 1].CellValue = null;

   this.grid.Model[1, 1].CurrencyEdit.NullValue = null;

 

 

 

Regarding Query #2,

After deleting the value of that cell, the CellValue should be zero and not be empty or null. This is the default behavior of CurrencyEdit cell type.

 

Please let us know if you have any other queries.

 

Regards,

Pannir


Loader.
Live Chat Icon For mobile
Up arrow icon