tunhien
asked on
Select the final row when form load in datagridview (VS 05)!
I have a DataGridView and set the datasource of it equal to a datatable.
I wanna When It's load and show, the current cursor is set at the final record!
Please show me how to do that!?
I wanna When It's load and show, the current cursor is set at the final record!
Please show me how to do that!?
ASKER
No!
All I want is on the winform not on the web! :d
All I want is on the winform not on the web! :d
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
But if I wanna It wil select the new row! not the final row! --> how can I do that?
If your dataGridView have "Enable Adding" (AllowUserToAddRows = true) then the line I posted will select the new row.
If your dataGridView does not "Enable Adding", then you have to insert a new row in the datasource (your table) before you select the last row
ASKER
No!
I have to "Enable Adding" (AllowUserToAddRows = true) but if don't use
"yourDataGridView.CurrentC ell = yourDataGridView[0, yourDataGridView.Rows.Coun t - 1];"
It will select the first row.
And when I use the code above --> it select the final record but not the final row (new record).
And I tried with opmit "-1" in the code above but the IDE throw error when It ran.
I have to "Enable Adding" (AllowUserToAddRows = true) but if don't use
"yourDataGridView.CurrentC
It will select the first row.
And when I use the code above --> it select the final record but not the final row (new record).
And I tried with opmit "-1" in the code above but the IDE throw error when It ran.
ASKER
Sorry! :d
I don't know why when I set dataset in the constructor of form class instead of form_load so that when it load, the frist row is select first not the new row!
:d You're right!
I don't know why when I set dataset in the constructor of form class instead of form_load so that when it load, the frist row is select first not the new row!
:d You're right!
you can go like this
If Not Page.IsPostBack Then
dtgMaster.SelectedIndex = 0
BindMaster()
BindDetails()
End If
or you can go on live link
http://www.dotnetjohn.com/articles.aspx?articleid=14
thanks