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

Displaying blank decimal cells when zero

Is there any way of blanking a bound grid cell based on it's state without affecting its CellValue or its editability? The situation I have is as follows: An account sheet control has been implemented which has columns for a debit amount and a credit amount. These are bound to a Debit and a Credit property respectively. These properties are just different representations of a private decimal amount field. The properties change value according to: amount > 0 results in Debit=0 and Credit=amount amount < 0 results in Debit=amount and Credit = 0 amount == 0 results in Debit=Credit=0 I want to be able to have only one of the Debit or Credit columns have any information displayed in them at one time, but for the user to be able to edit either one i.e. as per a typical financial program. My initial attempt was to process the QueryCellInfo event and change the cell to a blank text cell at runtime if the credit/debit cell value was zero. This works fine for display, but when you edit the cell to change a credit to a debit or vice versa then the following error message pops up: "Object type cannot be converted to target type" Presumably this occurs because the QueryCellInfo processing turned that cell into a string previously. Whats the best way of achieving the financial credit/debit column blanking/editing functionality I'm looking for using the Essential grid?

2 Replies

AI Apolon Ivankovic May 21, 2003 03:48 AM

With some experimentation, I did find that setting the FormattedText property to an empty string in the QueryCellInfo event resulted in the functionality required. Is this a suitable solution?


AD Administrator Syncfusion Team May 21, 2003 03:53 AM

That should be fine. Setting Text to an empty string should also work or setting the CellValue to System.DbNull. If you supply a empty string for Text or FormattedText what is happening is that a System.DbNull will be assigned to CellValue. Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon