billyboy71
asked on
get datagridview to show last record instead of first.
Hi,
I was wondering is it possible to get the DATAGRID VIEW to show the last record instead of the first when it is initially loaded.
I am using VB.net with a Windows Form to display a table from Access 2003.
I was wondering is it possible to get the DATAGRID VIEW to show the last record instead of the first when it is initially loaded.
I am using VB.net with a Windows Form to display a table from Access 2003.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DataSet2.tblBeverages' table. You can move, or remove it, as needed.
Me.TblBeveragesTableAdapter.Fill(Me.DataSet2.tblBeverages)
ASKER
Hi,
Well, the last record in terms of the last row?
I was thinking about using FirstDisplayedScrollingRow Index , but I can't seem to get it to work.
Peter
Well, the last record in terms of the last row?
I was thinking about using FirstDisplayedScrollingRow
Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
Thanks for the reply. I tried the suggestions above. But I can't seem to get the arrow pointer to go to the particular row when the datagridview is loaded . Is there some execute command that I need to carry out?
Peter
Thanks for the reply. I tried the suggestions above. But I can't seem to get the arrow pointer to go to the particular row when the datagridview is loaded . Is there some execute command that I need to carry out?
Peter
ASKER
Hi,
Thanks for your reply. Now , I can get the arrow pointer to scroll to the button , but only when I put the the command in a particular method such as when I put the command in a button click.
But I want it to got to that row when the form appears.
Peter
Thanks for your reply. Now , I can get the arrow pointer to scroll to the button , but only when I put the the command in a particular method such as when I put the command in a button click.
But I want it to got to that row when the form appears.
Peter
ASKER
Hi,
Is there some kind of method for the Form or Tab, Such as Form.Onfocus or Tab.Onfocus so that it can execute the method of DataGridView.FirstDisplaye dScrolling RowIndex = 3 ?
Otherwise, the form just won't execute it unless I put it in a button on_click method or somethign.
peter
Is there some kind of method for the Form or Tab, Such as Form.Onfocus or Tab.Onfocus so that it can execute the method of DataGridView.FirstDisplaye
Otherwise, the form just won't execute it unless I put it in a button on_click method or somethign.
peter
ASKER
Hi,
This is strange it can't carry out that command on the FORM LOAD event. But I can do it on the Button Click event.
Me.DataGridView2.FirstDisp layedScrol lingRowInd ex = Me.DataGridView2.RowCount - 1
Peter
This is strange it can't carry out that command on the FORM LOAD event. But I can do it on the Button Click event.
Me.DataGridView2.FirstDisp
Peter
Hi Peter,
This selects the record and show the arrow pointer.
Me.DataGridView.Rows(3).Se lected = True
Can you show your code that you are trying to use ? If you are using this on form load maybe it's to quick and doesn't see anything. Try to do this way or you can add a timer to delay this action:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TblBeveragesTableAdapte r.Fill(Me. DataSet2.t blBeverage s)
Applications.DoEvents()
Me.DataGridView2.FirstDisp layedScrol lingRowInd ex = Me.DataGridView2.RowCount - 1
End Sub
This selects the record and show the arrow pointer.
Me.DataGridView.Rows(3).Se
Can you show your code that you are trying to use ? If you are using this on form load maybe it's to quick and doesn't see anything. Try to do this way or you can add a timer to delay this action:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TblBeveragesTableAdapte
Applications.DoEvents()
Me.DataGridView2.FirstDisp
End Sub
ASKER
Hi Ipaulino,
I found out what my problem was. The first code that you gave works now. The problem was that my Datagridview was inside a Tab Control. So in order to get it to work I had to put the code in the Tab Control event.
Thanks a lot.
Peter
I found out what my problem was. The first code that you gave works now. The problem was that my Datagridview was inside a Tab Control. So in order to get it to work I had to put the code in the Tab Control event.
Thanks a lot.
Peter
Private Sub TabControl1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.Click
Me.DataGridView2.FirstDisplayedScrollingRowIndex = Me.DataGridView2.RowCount - 1
End Sub
>> The problem was that my Datagridview was inside a Tab Control. So in order to get it to work I had to put the code in the Tab Control event.
It happens allot! :-)
Glad I could help and thank for the grade!
It happens allot! :-)
Glad I could help and thank for the grade!
Ho do you define last record ? Do you have any Id, date, etc ?
You can sort the datagridview to do that after you fill it.