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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Displaying blank decimal cells when zero

Thread ID:





4603 May 21,2003 03:35 AM UTC May 21,2003 07:53 AM UTC WinForms 2
Tags: GridControl
Apolon Ivankovic
Asked On May 21, 2003 03:35 AM UTC

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?

Apolon Ivankovic
Replied On May 21, 2003 07:48 AM UTC

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?

Administrator [Syncfusion]
Replied On May 21, 2003 07:53 AM UTC

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


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon