Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the Windows From application . I have a Datagridview. In that gridview, i bind some values using database..
Now if i click that bind value in the gridview that value is displayed in the particular Textbox.

How i do it.

Thanks in advance.
Posted
Updated 5-Nov-11 1:40am
v2

Hi,
I think you want to bind value of some database column to text box as soon as you bind to Grid View, if it is so, this will be helpful.
http://www.java2s.com/Code/CSharp/Database-ADO.net/DataViewBindingtoTextBox.htm[^]
 
Share this answer
 
Means on GridView cell click you want to fill that value to database. Right ?

after binding gridview successfully. Generate cell click event.

C#
private void dataGridView1_CellClick(object sender,DataGridViewCellEventArgs e)
{
   DataGridViewImageCell cell = (DataGridViewImageCell)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
   txtTextbox.text = cell.value; 

}
 
Share this answer
 
Comments
RaisKazi 5-Nov-11 7:46am    
My 5!
koolprasad2003 5-Nov-11 8:47am    
thanks
C#
textBox1.Text=dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].ToString();


use it in DataGridView Cell Click Event. When You click particular cell. It will fire and set the TextBox with value coming from Database.
Hope it helps...Happy Coding...:-)
 
Share this answer
 
Using DataGridView.CellClick Event.

Have a look at below link for more information.

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellclick.aspx
 
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