Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4
The following error exists in ultrawingrid version 10.2 and 10.3. It does not exist in version 8.3.
We are running into an error that has been hard to pinpoint, but the following source allows you to see a scenario where the error happens every time. First, in the ultrawingrid InitializeLayout event we set the ExpansionIndicator and LoadStyle.
Notice in the btnRemoveChildRecordAndCrash click event a parent record is activated and then a child row is deleted. The button click event generates the following error when _p1c1.Delete() executes.
Object reference not set to an instance of an object.
The btnRemoveChildRecordWithoutCrashing click event does the exact same thing without activating a row. Execution is completed without error.
If you comment out one or both of the properties set in the InitializeLayout event the error does not occur.
The row activation does not need to be in the button click event. The error will also occur if it is in the form load or somewhere else.
Please help?
Public Class Form1
Private _dataset As New DataSet
Private _childTable As New DataTable("ChildTable")
Private _parentTable As New DataTable("ParentTable")
Private _p1c1 As DataRow
Private WithEvents ugBasicGrid As New Infragistics.Win.UltraWinGrid.UltraGrid
Private WithEvents btnRemoveChildRecordAndCrash As New Button
Private WithEvents btnRemoveChildRecordWithoutCrashing As New Button
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ClientSize = New System.Drawing.Size(662, 404)
Me.ugBasicGrid.Location = New System.Drawing.Point(12, 12)
Me.ugBasicGrid.Name = "ugBasicGrid"
Me.ugBasicGrid.Size = New System.Drawing.Size(619, 315)
Me.Controls.Add(Me.ugBasicGrid)
InitializeDataSet()
ugBasicGrid.DataSource = _parentTable
Me.btnRemoveChildRecordAndCrash.Text = "Remove Child Record (and crash)"
Me.btnRemoveChildRecordAndCrash.Location = New System.Drawing.Point(12, 344)
Me.btnRemoveChildRecordAndCrash.Size = New System.Drawing.Size(184, 23)
Me.Controls.Add(Me.btnRemoveChildRecordAndCrash)
Me.btnRemoveChildRecordWithoutCrashing.Text = "Remove Child Record (no problem)"
Me.btnRemoveChildRecordWithoutCrashing.Location = New System.Drawing.Point(200, 344)
Me.btnRemoveChildRecordWithoutCrashing.Size = New System.Drawing.Size(184, 23)
Me.Controls.Add(Me.btnRemoveChildRecordWithoutCrashing)
End Sub
Private Sub InitializeDataSet()
_dataset.Tables.Add(_parentTable)
_parentTable.Columns.Add(New DataColumn("ParentID", GetType(Integer)))
_parentTable.Columns.Add(New DataColumn("ParentDescription", GetType(String)))
_parentTable.Rows.Add("1", "parent one")
_parentTable.Rows.Add("2", "parent two")
_childTable.Columns.Add(New DataColumn("ParentID", GetType(Integer)))
_childTable.Columns.Add(New DataColumn("ChildID", GetType(String)))
_childTable.Columns.Add(New DataColumn("ChildDescription", GetType(String)))
_p1c1 = _childTable.Rows.Add("1", "p1c1", "parent one child one")
_dataset.Tables.Add(_childTable)
_dataset.Relations.Add("Relation", _dataset.Tables("ParentTable").Columns("ParentID"), _dataset.Tables("ChildTable").Columns("ParentID"), False)
Private Sub btnRemoveChildRecordAndCrash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemoveChildRecordAndCrash.Click
If _p1c1 Is Nothing Then
MsgBox("please restart the program before clicking any more buttons.")
Return
End If
ugBasicGrid.Rows(1).Activate()
_p1c1.Delete()
_p1c1 = Nothing
_childTable.AcceptChanges()
MsgBox("Child row removed.")
Private Sub btnRemoveChildRecordWithoutCrashing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemoveChildRecordWithoutCrashing.Click
'ugBasicGrid.Rows(1).Activate()
Private Sub ugBasicGrid_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles ugBasicGrid.InitializeLayout
ugBasicGrid.DisplayLayout.Bands(0).Override.ExpansionIndicator = Infragistics.Win.UltraWinGrid.ShowExpansionIndicator.CheckOnDisplay
ugBasicGrid.DisplayLayout.LoadStyle = Infragistics.Win.UltraWinGrid.LoadStyle.LoadOnDemand
End Class
Hi,
It's hard to do much with a code snippet. Can you post a small sample project here so I can check this out?
It might also help if you posted the whole call stack.
Does the error only occur when you set LoadStle to LoadOnDemand? If so, then I am pretty sure this was just recently fixed. Are you using the latest service release?
How to get the latest service release - Infragistics Community
Hi Mike,The code snippet provided is a complete form class. You can paste it into the code section of a form in a new visual basic project in visual studio, add the infragistic references, and the sample windows form project will run for you.As stated in my original post I tested this in 8.3, 10.2, and 10.3. I just downloaded the latest 10.3 version on December 29 and I ran the test again today copying the example code above and pasting it into the project using the 10.3 dll's to triple check myself.
If the LoadStyle is set to LoadOnDemand the error occurs. If I comment out the LoadStyle line of code the error does not occur. This error has been giving me a hard time to pinpoint and I finally got it into a test case where I could pass it along to you guys.
Thanks,Kurt
Hi Kurt,
Kurt said:The code snippet provided is a complete form class. You can paste it into the code section of a form in a new visual basic project in visual studio, add the infragistic references, and the sample windows form project will run for you.
It's always better to have a complete sample. With a code snippet, there are a lot of unknowns, like what version of Visual Studio you are using, for example, and which Infragistics references you are using.
Your code snippet is a lot easier than most, since you are declaring all of the controls directly in the code. If you added the controls to the form designer, they would have ended up in the Designer.cs file and that makes even more guesswork.
Anyway, your code snippet is, in fact, a lot simpler than most, and I tried this out and it was no trouble at all to make it run. I used VS2008, FYI, not that it's likely to matter with this particular issue. :)
I've got good news, bad news, and more good news.
The good news is that I was right. Your sample works perfectly fine for me and there is no crash, so it looks like this is already fixed. The bad news is that the fix is not publicly available, yet. The more good news is that you don't have to wait long. The next service release is due out later this month.
You can find the latest eta on the service release here: Infragistics Service Releases
And once it's released, here's how to get it: How to get the latest service release - Infragistics Community
Please let us know if the service release doesn't fix it, but I'm pretty sure it will.
I will get the next release when it comes out. Thank you for your help.