3
Reply

How to navigate to a record in Datagridview

Madito Kevin

Madito Kevin

Apr 6 2015 5:58 AM
804
I want to navigate to a record in Datagridview by selecting/click on a record without using a button click.
and display a record number,or current record number. 
Please help here is my code snippet.
 
 
private void labelUpdate()
{
if (hwdg.SelectedRows.Count>=inc)
{
hwdg.FirstDisplayedScrollingRowIndex = inc;
hwdg.Rows[inc].Selected = true;
//inc++;
label27.Text = "Record" + (inc + 1) + " of " + ds2.Tables["tblComp"].Rows.Count;
}
else if(hwdg.SelectedRows.Count<=inc)
{
hwdg.Rows[inc - 1].Selected = true;
label27.Text = "Record" + (inc + 1) + " of " + ds2.Tables["tblComp"].Rows.Count;
}
}
 
 
 
 

Answers (3)