Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1705
ToolStripMenuItem click event Sets the data source of the grid to null
posted

 

Hey guys, 

I have a grid in a form that is contained in a MDI form (the grid form is created by clicking an item of an UltraExplorerBar control), and there are a few ToolStripMenuItem controls in the MDI form that are intended to work as an Edit menu (copy, paste, cut, etc) .

I have added an event handler in the grid form for the click events of the ToolStripMenuItem controls .

The grid seems to work fine, we are able to insert new rows, update, sort, copy, paste, etc, etc.

The problem is when we close the form and create it again (we initialize it by using the form constructor). Clicking on the ToolStripMenuItem control will magically set the DataSource of the Grid to null.

I tried to "fix" it by re-assigning the list of objects to the grid, but I got the following exception in the line Grid.DataSource= ObjList:

 

 "Object reference not set to an instance of an object."

"Infragistics2.Win.UltraWinGrid.v8.2"


   at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember)
   at Infragistics.Win.UltraWinGrid.UltraGridBase.set_DataSource(Object value)
   at MyProject.DataEntryGrid.SetDataSource() in C:\Documents and Settings\ureyes\My Documents\Visual Studio 2008\Projects\MyProject\UserControls\DataEntryGrid.cs:line 718
   at MyProject.DataEntryGrid.BindGridData() in C:\Documents and Settings\ureyes\My Documents\Visual Studio 2008\Projects\MyProject\UserControls\DataEntryGrid.cs:line 317
   at MyProject.DataEntryGrid.CopySelection(Boolean RemoveSelection) in C:\Documents and Settings\ureyes\My Documents\Visual Studio 2008\Projects\MyProject\UserControls\DataEntryGrid.cs:line 1585
   at MyProject.DataEntryGrid.cutToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Documents and Settings\ureyes\My Documents\Visual Studio 2008\Projects\MyProject\UserControls\DataEntryGrid.cs:line 1572

   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)

 

Any help would be appreciated.

Thanks !

 

Parents Reply Children
No Data