RowContaining, ColContaining Method Example

This example saves the value of the cell where the user began a drag method.

Dim SaveValue
Sub DataGrid1_MouseDown (Button As Integer, Shift As Integer, _
 X As Single, Y As Single)
   Dim RowValue, ColValue
   ' Get the value of the row and column that the mouse is over
   RowValue = DataGrid1.RowContaining(Y)
   ColValue = DataGrid1.ColContaining(X)
   ' If the values are both valid, save the text of the cell and
   ' begin dragging.
   If RowValue > 0 And RowValue < DataGrid1.VisibleRows And _
    ColValue > 0 And ColValue < DataGrid1.VisibleCols Then
      SaveValue = DataGrid1.Columns(ColValue). _
      CellValue(DataGrid1.RowBookmark(RowValue))
      DataGrid1.Drag 1
   End If
End Sub