| |

VerySource

 Forgot password?
 Register
Search
View: 2621|Reply: 13

Vb6 selected row in dbgrid

[Copy link]

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-7 13:20:01
| Show all posts |Read mode
Get the row where dbgrid selects, it can't be obtained using the row attribute, I don't know what's going on ...

Please heroes advice, thank you!
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-7 20:27:01
| Show all posts
Or get the value of the column in the current row,
First time using dbgrid, not very likely ...
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-9 11:36:01
| Show all posts
The value in dbgrid is the display of the recordset. The selected row ado1.recordset.fields (0) .value can return the value of the specific column.
Reply

Use magic Report

1

Threads

19

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 United States

Post time: 2020-1-10 13:27:01
| Show all posts
Set DataGrid2.DataSource = Rs
DataGrid2.Row = 3
I tested it, so it works. At this time, DataGrid2 points to the fourth row, (the row number starts from 0)
Reply

Use magic Report

1

Threads

19

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-1-10 13:54:02
| Show all posts
Set DataGrid2.DataSource = tblnameRs
    DataGrid2.Row = 3
    MsgBox DataGrid2.Row
This is feasible, I tried
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-10 14:18:01
| Show all posts
Do I have to recordset to find the corresponding value?
Can it be obtained from the properties of dbgrid? If something like mshflexgrid's text.
Reply

Use magic Report

1

Threads

19

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-1-10 15:27:02
| Show all posts
set datagrid1.DataSource = rs
datagrid1.row = 3
msgbox datagrid1.row 'value is 3
Reply

Use magic Report

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-22 20:18:01
| Show all posts
The datagrid property can only get the current row of the datagrid table, not the recordset.
If your datagrid can only display 10 records at a time,
When you click the last row of datagrid, the value returned by datagrid.row will always only be 10.
It doesn't matter how many records your record is in the table.
It's hard to say, you know what's going on.

Private Sub DataGrid1_RowColChange (LastRow As Variant, ByVal LastCol As Integer)
Text1.Text = datagrid.Row
End Sub

The following is the value obtained using the Bookmark property of the Recordset

Private Sub DataGrid1_RowColChange (LastRow As Variant, ByVal LastCol As Integer)
Text1.Text = Adodc1.Recordset.Bookmark
End Sub
Reply

Use magic Report

0

Threads

18

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-24 12:00:01
| Show all posts
Agree upstairs
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Thailand

 Author| Post time: 2020-1-24 20:45:01
| Show all posts
Note that datagrid is not equal to dbgrid. Different controls ...
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list