Click here to Skip to main content
15,943,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I have some confusion on data binding between datagridview and textbox.

Issue Description:
I want to bind datatable's data in datagridview and textbox, and when I

clicked the datagridview row, then textbox would get corresponding data in

datagridview and show in textbox. My problem is when I added the new empty row and

then I clicked this row, but can't clear textbox, still remained last row data.

You can check my implementation as below. Thank in advance.

Private Sub InitCPN()

   Me.dgvCPN.DataSource = Me._dsSFC.Tables("CPNInfo")                '''' Binding data table to the data grid view.

   ////Textbox binding datatable.
   Me.txtSN2.DataBindings.Add("Text", Me._dsSFC.Tables("CPNInfo"), "SN2Pattern")
   Me.txtSN3.DataBindings.Add("Text", Me._dsSFC.Tables("CPNInfo"), "SN3Pattern")
   Me.txtSN4.DataBindings.Add("Text", Me._dsSFC.Tables("CPNInfo"), "SN4Pattern")
Updated 6-Jun-11 22:50pm

1 solution

Hope this[^] might help you.
Share this answer
jkhuang 7-Jun-11 4:57am    
I can bind datagridview data in separate textbox, but I can change textbox data when I clicked corresponding row, but I clicked last empty row can't change textbox data to empty.

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