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

Getting "Object reference not set to an instance of an object’"

Hi,

I need a favour from you guys, Iam using one custom grid control, which is inherited from "Syncfusion.Windows.Forms.Grid.GridDataBoundGrid", one more custom grid column cell model control, which is inherited GridDropDownGridListControlCellModel and Windows Forms.

My form is using the custom grid control, this grid is having two columns, both are required fields to add an entry in the database. So when the gives only one field information and tries to close the form by clikcing the form closing(X). First time when user click the form closing then will receive error message "Required field is missing". Again if he press the form closing then will receive the "Object reference not set to an instance of an object".

When user tries to close the form at first time, grid row leave will execute, here iam calling e.Cancel=true and following events occurs.

- gdbgResults_CurrentCellValidating
- gdbgResults_CurrentCellAcceptedChanges
- gdbgResults_RowLeave

When user press the form closing button second time, only "gdbgResults_CurrentCellValidating" was executed and then receives the error message.

Observation:

- Grid validation becomes fail
- Grid cell moving becomes fail.

Please advice me how to proceed to avoid the error when user press the for closing button any time.

Sample85.zip

3 Replies

AD Administrator Syncfusion Team November 30, 2006 11:18 AM UTC

Hi kesavulu,

We were not able to reproduce the issue here. Could you please provide a sample having the issue? This will help us to analyse the issue further.

Thanks for your patience.

Best Regards,
Haneef


AD Administrator Syncfusion Team November 30, 2006 02:22 PM UTC

Hi Haneef,

Thanks for support.

I have given the source files in the previous mail. Could you please suggest what might be the problem to receive the error "Object reference not set to an instance".

Thanks,
Kesavulu

>Hi kesavulu,

We were not able to reproduce the issue here. Could you please provide a sample having the issue? This will help us to analyse the issue further.

Thanks for your patience.

Best Regards,
Haneef


AD Administrator Syncfusion Team December 6, 2006 10:41 AM UTC

Hi kesavulu,

You can override the form's WndProc method and dispose the form while clicking the close button. Here is a code snippet.

public const int SC_CLOSE = 0xF060;
public const int WM_SYSCOMMAND = 0x0112;

protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == WM_SYSCOMMAND && (int)m.WParam == SC_CLOSE)
{
this.Dispose();
}
base.WndProc(ref m);
}

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon