Reputation: 113
A little background first: I have a telnet session that is connected to a cluster, it stays connected and receives information periodically. Incoming information is processed and is displayed in a DataGrid. This happens in real time. Currently the newest information is displayed on the last row (bottom row). I would like the newest piece of information to be displayed on the top row instead.
DataGridView1.Rows.Add(New String() {InfoA, InfoB, InfoC, InfoD, InfoE})
DataGridView1.ClearSelection()
DataGridView1.FirstDisplayedScrollingRowIndex = DataGridView1.RowCount - 1
Any help would be appreciated.
Upvotes: 0
Views: 1216
Reputation: 647
Instead of using DataGridView1.Rows.Add() you can use DataGridView1.Rows.Insert() as this gives you an extra parameter and the ability to add the row at a specific row index, in your case a zero index I think will add the row to the datagrid as the topmost row:
DataGridView1.Rows.Insert(0, New String() {InfoA, InfoB, InfoC, InfoD, InfoE})
Upvotes: 1