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

QueryCellInfo problem

Thread ID:

Created:

Updated:

Platform:

Replies:

26423 Mar 22,2005 03:50 PM Mar 23,2005 09:35 AM Windows Forms 7
loading
Tags: GridControl
Virgil
Asked On March 22, 2005 03:50 PM

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 05:55 PM

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
Else
    PartType = _Grid(e.RowIndex, _GridColumnNumber.PartTypeCode).CellValue

Virgil
Replied On March 23, 2005 07:50 AM

That fixed the problem. Thanks =)

Virgil
Replied On March 23, 2005 08:02 AM

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

Virgil
Replied On March 23, 2005 08:18 AM

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 08:44 AM

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.

Virgil
Replied On March 23, 2005 09:11 AM

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 09:35 AM

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.

CONFIRMATION

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.

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.

;