Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using windows application C# and i want to retrieve selected row data in my text boxes.
so where i need to put my code?? which event
and what i need to write??
i am trying this but this is not working
C#
private void gvProdctTypName_CellContentClick(object sender, DataGridViewCellEventArgs e)
       {
          tbProductTypeName.Text = gvProdctTypName.SelectedRows[0].Cells[1].Value.ToString();
       }
Posted
Comments
Animesh Datta 10-Apr-14 6:38am    
what the error you are getting ?
[no name] 10-Apr-14 6:47am    
"but this is not working" tells us nothing about your problem. We cannot see your screen or read your mind.

1 solution

Quote:
so where i need to put my code?? which event

try add a handler to SelectionChanged event
C#
private void gvProdctTypName_SelectionChanged(object sender, EventArgs e)
{
  if (gvProdctTypName.CurrentRow != null)
    tbProductTypeName.Text = gvProdctTypName.CurrentRow.Cells[1].Value.ToString();
}
 
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