Madito Kevin

Madito Kevin

  • NA
  • 8
  • 2k

How to navigate to a record in Datagridview

Apr 6 2015 5:58 AM
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)