Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid row/col current cell ??

Status
Not open for further replies.

tcapp

Programmer
Apr 18, 2000
9
US
How can you determine the current row and col of a datagrid. Does the datagrid have something like the flexgrids TextMatrix property referencing both col and row?
 
Datagrid.col and Datagrid.row should serve your purpose ;)
Rob
"Programming is like art...It makes me feel like chopping my ear off."
 
Thanks again Rob....
I was trying to populate text boxes from the grid from a click event my code looks like this:

Private Sub DataGrid1_Click()
For x = 0 To 15
txtFields(x).Text = DataGrid1.Columns(x).Text
txtFields(x).Refresh
Next x
DataGrid1.Refresh
End Sub

Unfortunatly for some reason I have to double click on a cell to populate the text boxes...any idea how to make it a single click?
 
use an on mouseDown event...
This should get you started...keep in mind it's just off the top of my head...you'll probably have to edit it ;)

Private Sub DataGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
For I = 0 To 15
If X > DataGrid1.Columns(I).Left And X < (DataGrid1.Columns(I).Left + DataGrid1.Columns(I).Width) Then
TextBox(I).Text = DataGrid1.Columns(I).Text
End If
Next
End Sub Rob
&quot;Programming is like art...It makes me feel like chopping my ear off.&quot;
 
oops, forgot an end if there, after next ;) Rob
&quot;Programming is like art...It makes me feel like chopping my ear off.&quot;
 
Added the code and still get the same problem. I can click on a name and it doesnt update. If I double click it works, If I click on another name it shows the previous selection. Its always on record behind
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top