User (Old forums)MemberDecember 12, 2004 at 4:40 pmPost count: 23064
First I want to thank you for a wonderful and versatile component for different uses. It has given us a possibility to focus our core knowledge rather than working with the standard grid features.
Anyway, I have encountered a problem with the development work. We have a grid with certain unbounded DataRows. I should handle a double click in a certain Cell. Thanks for your good documentation, I’ve done the basic subscribe method with following code:
Dim cl As Xceed.Grid.Cell
For Each cl In Me.gridVartil.DataRowTemplate.Cells
AddHandler cl.DoubleClick, AddressOf gridcell_DblClick
I’ve defined the gridcell_DblClick like this:
Private Sub gridcell_DblClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim dCell As Xceed.Grid.DataCell
Dim dTag As String
dCell = CType(sender, Xceed.Grid.DataCell)
dTag = dCell.Tag.ToString
For some reason, this throws me the TargetInvocationException. If I comment out the last three lines, no error is given.
Imported from legacy forums. Posted by vmattila (had 2900 views)User (Old forums)MemberDecember 13, 2004 at 2:38 amPost count: 23064
Maybe dCell.Tag doesn’t have a value yet (Null value)? If dCell.Tag is Null then dCell.Tag.ToString will throw an exception. First check if it isn’t null.
Imported from legacy forums. Posted by Tommy (had 238 views)User (Old forums)MemberDecember 13, 2004 at 2:52 amPost count: 23064
Thanks for your answer Tommy. I have not been familiar with TargetInvocationException and I didn’t understood that it’s just an error that is caused due another error in a subscribed event. For my opinion, this should have been handled in a little bit better way in VB.NET. It takes some time to debug the code to find out the reason of the error. In fact, running the program not in the debug mode gives a better view on stacks.
Imported from legacy forums. Posted by vmattila (had 304 views)User (Old forums)MemberDecember 13, 2004 at 5:27 amPost count: 23064
To see the exact error: put the code in a Try..Catch(Exception ex) block, and in the Catch block, display the exception, with MsgBox ex.ToString()
You can also set a breakpoint on that line, and in the debugger you can check your variables.
Imported from legacy forums. Posted by Tommy (had 3974 views)
- You must be logged in to reply to this topic.