I am getting some strange results when trying to access data thrown into a
DataGrid. Perhaps someone can shed some light and provide a solution to my
issues....
Process:
Load DataGrid1 with an ADOrs - no problem
Click a cell to retrieve it's value - some problems
When clicked, I am *trying* to set the Row number like this,
Dim RowValue
RowValue = DataGrid1.RowContaining(Y)
What I get for the value is actually +1 from the ADOrs value (so, clicking a
cell in the first row will give me a RowValue = 1). No problem, just
subtract 1 ( -1) from the actual row number to access the correct row (0) in
the ADOrs, right? Well, this works for rows 1 thru 3 in the DataGrid1.
Here's what happens past row 3:
Clicking a cell in row #4 in the DataGrid returns a RowValue = 5!!!! So, by
subtracting 1 from this, gives me row 4 in the ADOrs which is the inncorect
value from where I clicked. It should be giving me a RowValue = 4 (which in
turn would select row 3 in the ADOrs).
Also -- when clicking on or past row 5 in the DataGrid, it returns a
RowValue = -1 which of course totally throws everything off and bombs out the
app.
Any insight as to this behavior and how to remedy would be greatly
appreciated. Code below.
Thanks,
j
Private Sub dataGrid1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As stdole.OLE_XPOS_PIXELS, ByVal Y As stdole.OLE_YPOS_PIXELS)
Dim RowValue, ColValue
Dim cellVal As String
Dim pos As Integer
ColValue = DataGrid1.ColContaining(X)
RowValue = DataGrid1.RowContaining(Y)
pos = RowValue - 1
cellVal = DataGrid1.Columns("ID").CellText(DataGrid1.RowBookmark(pos))
End Sub