Hi,
I have 2 radgridview. From gridOCC (source), I dragdrop its id to another grid grdDest (Destination). After dragdropping, I get error when I scroll grdOCC. Nothing has been changed in grdOCC, but still I get error on scrolling. I have the code below (this is underlined below), to exit if the user clicks on the scroll bar. Still it gives error. The code that is bold is where the error kicks out. I have shown the error I am getting all the way below in the post.
Here is the code that throws exception:
Private Sub grdOCC_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles grdOCC.MouseDown
Dim iOCCRowIndex As Integer = 0
Dim iOCCColIndex As Integer = 0
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridHeaderCellElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridTableHeaderCellElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridRowHeaderCellElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.RadCheckBoxEditorElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridFilterCellElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridCheckBoxCellElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.RadScrollBarElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.ScrollBarThumb Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridCellElement Then
Dim gridPointOCC As Point = grdOCC.PointToClient(Windows.Forms.Cursor.Position)
Dim elm As Telerik.WinControls.UI.GridDataCellElement
If gridPointOCC.GetType = Nothing Then Exit Sub
elm = grdOCC.ElementTree.GetElementAtPoint(New Point(gridPointOCC.X, gridPointOCC.Y))
If elm.RowIndex < 0 Then Exit Sub
iOCCRowIndex = elm.RowIndex
If iOCCRowIndex >= 0 And elm.ColumnInfo.Name = "ID" Then
grdOCC.Update()
iOCCQty = CInt(grdOCC.CurrentRow.Cells("quantity").Value)
strOCCExch = grdOCC.CurrentRow.Cells("exch_code").Value.ToString
strOCCSide = grdOCC.CurrentRow.Cells("side").Value.ToString
strOCCPC = grdOCC.CurrentRow.Cells("pc").Value.ToString
strOCCSymbol = grdOCC.CurrentRow.Cells("o_sym").Value.ToString
dblOCCStrike = CDbl(grdOCC.CurrentRow.Cells("strk").Value)
grdOCC.DoDragDrop(grdOCC.CurrentRow.Cells(1).Value.ToString, DragDropEffects.Copy) 'OCCID
End If
End If
End Sub
The error I get is:
---------------------------
Grid OCC MouseDown - Fix Exceptions
---------------------------
Unable to cast object of type 'Telerik.WinControls.UI.RadScrollBarElement' to type 'Telerik.WinControls.UI.GridDataCellElement'.
---------------------------
OK
---------------------------
I have 2 radgridview. From gridOCC (source), I dragdrop its id to another grid grdDest (Destination). After dragdropping, I get error when I scroll grdOCC. Nothing has been changed in grdOCC, but still I get error on scrolling. I have the code below (this is underlined below), to exit if the user clicks on the scroll bar. Still it gives error. The code that is bold is where the error kicks out. I have shown the error I am getting all the way below in the post.
Here is the code that throws exception:
Private Sub grdOCC_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles grdOCC.MouseDown
Dim iOCCRowIndex As Integer = 0
Dim iOCCColIndex As Integer = 0
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridHeaderCellElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridTableHeaderCellElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridRowHeaderCellElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.RadCheckBoxEditorElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridFilterCellElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridCheckBoxCellElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.RadScrollBarElement Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.ScrollBarThumb Then Exit Sub
If TypeOf (grdOCC.FocusedElement) Is Telerik.WinControls.UI.GridCellElement Then
Dim gridPointOCC As Point = grdOCC.PointToClient(Windows.Forms.Cursor.Position)
Dim elm As Telerik.WinControls.UI.GridDataCellElement
If gridPointOCC.GetType = Nothing Then Exit Sub
elm = grdOCC.ElementTree.GetElementAtPoint(New Point(gridPointOCC.X, gridPointOCC.Y))
If elm.RowIndex < 0 Then Exit Sub
iOCCRowIndex = elm.RowIndex
If iOCCRowIndex >= 0 And elm.ColumnInfo.Name = "ID" Then
grdOCC.Update()
iOCCQty = CInt(grdOCC.CurrentRow.Cells("quantity").Value)
strOCCExch = grdOCC.CurrentRow.Cells("exch_code").Value.ToString
strOCCSide = grdOCC.CurrentRow.Cells("side").Value.ToString
strOCCPC = grdOCC.CurrentRow.Cells("pc").Value.ToString
strOCCSymbol = grdOCC.CurrentRow.Cells("o_sym").Value.ToString
dblOCCStrike = CDbl(grdOCC.CurrentRow.Cells("strk").Value)
grdOCC.DoDragDrop(grdOCC.CurrentRow.Cells(1).Value.ToString, DragDropEffects.Copy) 'OCCID
End If
End If
End Sub
The error I get is:
---------------------------
Grid OCC MouseDown - Fix Exceptions
---------------------------
Unable to cast object of type 'Telerik.WinControls.UI.RadScrollBarElement' to type 'Telerik.WinControls.UI.GridDataCellElement'.
---------------------------
OK
---------------------------