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

QueryCellInfo problem

Thread ID:





26423 Mar 22,2005 08:50 PM UTC Mar 23,2005 02:35 PM UTC WinForms 7
Tags: GridControl
Asked On March 22, 2005 08:50 PM UTC

I am using a databound hierarchical grid and attempting to set certain cells to readonly depending on the data contained on a different column in the row. (i.e. The row is a prt and depending on the part type some fields should not be entered). When accessing the part type in the QueryCellInfo the grid displays a large red X with a white background. Below is the line of code which, when included, causes this behavior. Thanks in advance for any help, Virgil PartType = _Grid(e.RowIndex, _GridColumnNumber.PartTypeCode).CellValue

Administrator [Syncfusion]
Replied On March 22, 2005 10:55 PM UTC

If e.ColIndex is equal to _GridColumnNumber.PartTypeCode, then you should not try to use an indexer to get the value. Instead, just get the value from e.Style.CellValue.
If e.ColIndex = _GridColumnNumber.PartTypeCode Then
    PartType = e.Style.CellValue
    PartType = _Grid(e.RowIndex, _GridColumnNumber.PartTypeCode).CellValue

Replied On March 23, 2005 12:50 PM UTC

That fixed the problem. Thanks =)

Replied On March 23, 2005 01:02 PM UTC

I spoke too soon. Forgot to comment back in my event. I DO still get the red X. No error message.

Replied On March 23, 2005 01:18 PM UTC

Ok. The fix you provided does let the code get farther. The line in question is now: e.Style.CellValue = String.Format("{0.####}", e.Style.CellValue) With no other events handled by the grid except the QueryCellInfo, all code except a command such as this throws no errors.

Administrator [Syncfusion]
Replied On March 23, 2005 01:44 PM UTC

The big red X means an exception is being thrown during the Paint. Maybe e.Style.CellValue is null or DBNull.Value and this is causing this exception. If so, you should check for null before trying to format it.

Replied On March 23, 2005 02:11 PM UTC

Mr. Burch, Thank your for the help you have given thus far on this issue. Per your suggestion I have added code to check for DBNull, however I am still receiving the error. On further testing, it appears that the problem only occurs when attempting to edit a cell where I have changed the CellValue in the QueryCellInfo event. The error is received while following the steps below. For each step I have attached a screenshot so you can see what is being presented by the grid 1. Data is presented and is formatted correctly (databound, hierarchical grid) 2. Change the cell value (QuotedReturnablePackageTotalCost) 3. Leave the row (Red X appears) Excerpt of code from the QueryCellInfo event: Case _GridColumnNumber.QuotedReturnablePackageTotalCost If IsDBNull(e.Style.CellValue) Then e.Style.CellValue = "" Else e.Style.CellValue = String.Format("{0.####}", e.Style.CellValue) End If e.Handled = True WinCES_8565.zip

Administrator [Syncfusion]
Replied On March 23, 2005 02:35 PM UTC

I am not sure what project you attached, and I may have missed something but I did not see any syncfusion references in it. As far as the error goes, is the CellValue a double? If so, you cannot set it to be a string value as you are trying to to. So, try code like
If Not IsDBNull(e.Style.CellValue) Then
    e.Style.CellValueType = GetType(double)
    e.Style.Format = "0.####"
End If
The idea is not to change the CellValue, but to make sure the style.Format is set the way you want it. In order for the style.Format to take effect, style.CellValueType must be set properly as well.


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