Datagrid Boolean Column Sorting

G

Guest

Hi,

When we are sorting the DataGrid Boolean column the grid is becoming
redcross.

I have my own PPMIPDataGridBoolColumn class inherited from
System.Windows.Forms.DataGridBoolColumn. In this inherited class I have one
DataGridValueChangedEventHandler event handler. I am overriding Edit() to
know the current state of the cell. I am overriding Paint() to know the if
the user has been editing the cell. I am also overriding the Commit() to
commit the cell's data in the underlying datasource.

In this whole scenario there is no problem if we donot sort the boolean
column and try to check and uncheck the checkboxes. When we sort the boolean
column and try to check the checkbox following is happening.

A dialogbox with caption Microsoft .Net Framework is coming with following
message with three buttons. "Details", "Continue" and "Quit"

**********************************************************
"An unhandled exception has occured in your application. If you click
Continue, the application will ignore this error and attempt to continue. If
you click Quit, the application will be shut down immediately"
**********************************************************

Clicking on "Quit" button is quits the application

If I click on "Continue" button another messagebox is coming with caption
"Error when committing the row to the original data source."
and message
"Error in the application. Do you want to correct the value?"

Whatever button you choose to click i.e. 'Yes' or 'No' the messaagebox is
going away but the red cross exists.

I have no clue why this is happening? Please help me I am in deep trouble.

Clicking on "Details" button shows the error message in details which I am
pasting it below.
**********************************************************
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
PPMIP.Common.PPMIPException: Error in the application.
at PPMIP.Clients.OnlineForms.PPMIPDataGridBoolColumn.Paint(Graphics
vgraGraphic, Rectangle vrecBounds, CurrencyManager vcumSource, Int32
vintRowIndex, Brush vbruBack, Brush vruFore, Boolean vblnAlignToRight) in
c:\raj personal\ppmip\clients\onlineforms\ppmipdatagridboolcolumn.cs:line 311

at
System.Windows.Forms.DataGridRelationshipRow.PaintCellContents(Graphics g,
Rectangle cellBounds, DataGridColumnStyle column, Brush backBr, Brush
foreBrush, Boolean alignToRight)

at System.Windows.Forms.DataGridRow.PaintData(Graphics g, Rectangle
bounds, Int32 firstVisibleColumn, Int32 columnCount, Boolean alignToRight)

at System.Windows.Forms.DataGridRelationshipRow.Paint(Graphics g,
Rectangle bounds, Rectangle trueRowBounds, Int32 firstVisibleColumn, Int32
numVisibleColumns, Boolean alignToRight)

at System.Windows.Forms.DataGrid.PaintRows(Graphics g, Rectangle&
boundingRect)

at System.Windows.Forms.DataGrid.PaintGrid(Graphics g, Rectangle
gridBounds)

at System.Windows.Forms.DataGrid.OnPaint(PaintEventArgs pe)

at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,
Int16 layer, Boolean disposeEventArgs)

at System.Windows.Forms.Control.WmPaint(Message& m)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
PPMIP
Assembly Version: 1.0.8.0
Win32 Version: 1.0.8.0
CodeBase: file:///C:/Raj%20Personal/PPMIP/Bin/Debug/PPMIP.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dl
----------------------------------------
CommonClassCode
Assembly Version: 1.0.2032.24934
Win32 Version: 1.0.2032.24934
CodeBase: file:///C:/Raj%20Personal/PPMIP/Bin/Debug/CommonClassCode.DLL
----------------------------------------
PPMIP.Common.Resources
Assembly Version: 1.0.2032.23947
Win32 Version: 1.0.2032.23947
CodeBase:
file:///C:/Raj%20Personal/PPMIP/Bin/Debug/PPMIP.Common.Resources.DLL
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data.OracleClient
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.data.oracleclient/1.0.5000.0__b77a5c561934e089/system.data.oracleclient.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
**********************************************************
 
C

Chris

Raj said:
Hi,

When we are sorting the DataGrid Boolean column the grid is becoming
redcross.

I have my own PPMIPDataGridBoolColumn class inherited from
System.Windows.Forms.DataGridBoolColumn. In this inherited class I have one
DataGridValueChangedEventHandler event handler. I am overriding Edit() to
know the current state of the cell. I am overriding Paint() to know the if
the user has been editing the cell. I am also overriding the Commit() to
commit the cell's data in the underlying datasource.

In this whole scenario there is no problem if we donot sort the boolean
column and try to check and uncheck the checkboxes. When we sort the boolean
column and try to check the checkbox following is happening.

A dialogbox with caption Microsoft .Net Framework is coming with following
message with three buttons. "Details", "Continue" and "Quit"

**********************************************************
"An unhandled exception has occured in your application. If you click
Continue, the application will ignore this error and attempt to continue. If
you click Quit, the application will be shut down immediately"
**********************************************************

Clicking on "Quit" button is quits the application

If I click on "Continue" button another messagebox is coming with caption
"Error when committing the row to the original data source."
and message
"Error in the application. Do you want to correct the value?"

Whatever button you choose to click i.e. 'Yes' or 'No' the messaagebox is
going away but the red cross exists.

I have no clue why this is happening? Please help me I am in deep trouble.

Clicking on "Details" button shows the error message in details which I am
pasting it below.
**********************************************************
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
PPMIP.Common.PPMIPException: Error in the application.
at PPMIP.Clients.OnlineForms.PPMIPDataGridBoolColumn.Paint(Graphics
vgraGraphic, Rectangle vrecBounds, CurrencyManager vcumSource, Int32
vintRowIndex, Brush vbruBack, Brush vruFore, Boolean vblnAlignToRight) in
c:\raj personal\ppmip\clients\onlineforms\ppmipdatagridboolcolumn.cs:line 311

at
System.Windows.Forms.DataGridRelationshipRow.PaintCellContents(Graphics g,
Rectangle cellBounds, DataGridColumnStyle column, Brush backBr, Brush
foreBrush, Boolean alignToRight)

at System.Windows.Forms.DataGridRow.PaintData(Graphics g, Rectangle
bounds, Int32 firstVisibleColumn, Int32 columnCount, Boolean alignToRight)

at System.Windows.Forms.DataGridRelationshipRow.Paint(Graphics g,
Rectangle bounds, Rectangle trueRowBounds, Int32 firstVisibleColumn, Int32
numVisibleColumns, Boolean alignToRight)

at System.Windows.Forms.DataGrid.PaintRows(Graphics g, Rectangle&
boundingRect)

at System.Windows.Forms.DataGrid.PaintGrid(Graphics g, Rectangle
gridBounds)

at System.Windows.Forms.DataGrid.OnPaint(PaintEventArgs pe)

at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,
Int16 layer, Boolean disposeEventArgs)

at System.Windows.Forms.Control.WmPaint(Message& m)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
PPMIP
Assembly Version: 1.0.8.0
Win32 Version: 1.0.8.0
CodeBase: file:///C:/Raj%20Personal/PPMIP/Bin/Debug/PPMIP.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dl
----------------------------------------
CommonClassCode
Assembly Version: 1.0.2032.24934
Win32 Version: 1.0.2032.24934
CodeBase: file:///C:/Raj%20Personal/PPMIP/Bin/Debug/CommonClassCode.DLL
----------------------------------------
PPMIP.Common.Resources
Assembly Version: 1.0.2032.23947
Win32 Version: 1.0.2032.23947
CodeBase:
file:///C:/Raj%20Personal/PPMIP/Bin/Debug/PPMIP.Common.Resources.DLL
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data.OracleClient
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.data.oracleclient/1.0.5000.0__b77a5c561934e089/system.data.oracleclient.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windows/assembly/gac/system.enterpriseservices/1.0.5000.0__b03f5f7f11d50a3a/system.enterpriseservices.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
**********************************************************


The reason you are getting the RedCross in the datagrid is because of
you overriding the paint method. I had the same problem. What is
probably happening is that you are referencing a member of your class
that is set to nothing before you instantiate the class. Since the
designer runs the paint method to show it on the screen it gets an
exception when you try to run the paint method. Look through your code,
and see if there are any variables that would be nothing if you just ran
the paint method by itself. If there are, enclose the entire function
in a if (Var != null). I think that is the right code, do mostly VB.
then at least you will get ride of the redcross. There is probably a
better way to do that. something to do with checking if you are in
designer mode, I don't know what it is though.

Chris
 
G

Guest

Hi,

Chris thank you for your answer. I went through my code and saw there is no
variables that is becoming nothing. So the problem is still there. I have got
no clue what is happening.
Does anyone know how to solve this problem.

Regards
Raj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top