Click here to Skip to main content
15,909,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have DataGridView control in windows form.How can i select a particular row values in that control.I am not able to see the selected index changed event of datagridview in windows so that i can get the control on particular row.As soon as i select a praticular row in datagridview control i need to get the complete row values and need to populate those values in textbox controls.Can anyone help on this?

Thanks in Advance
Prahsanth
Posted

1 solution

Dear Friend,

I take that you are selecting the row with the help of checkbox then write the code on the checkbox changed event of the grid :-

private void chkSelect_CheckedChanged(object sender, EventArgs e)
{
  try
  {
   CheckBox chk = new CheckBox();
   chk = sender as CheckBox;

   if(chk.Checked == true)
   {
     foreach(DataGridViewRow row in dgvDetails.Rows)
     {
       [here you can find all the controls and there value and then you can put them into appropriate variables and use them accordingly].
     }
   }
  }
  catch(Exception ex)
  {
    MessageBox.Show(ex.Message())
  }
}


Please don't forget to mark this as your answer if it helps you out.

Thanks

Varun Sareen
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900