Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Textbox on datagrid click

Status
Not open for further replies.

thefox149

Technical User
Nov 22, 2004
158
AU
I am new to vb.net please be gentle..

I have a datagrid i use for searching. When the user clicks the record they want I want the textbox to reflect the record selected. I want them to be bound so that I can call the adapters update method for minimal coding. I am sure I can code this the long way

I have bound the text box to the dataset but it only shows the first record I would have thought that it would disply they same data when changed as they are both bound to the same data set any way here is the code..also my row count doesn't work



dapStaff = New SqlDataAdapter(sQuery, cnn)

dapStaff.Fill(ds, "tblStaff")

bld1 = New SqlCommandBuilder(dapStaff)

Main.dgSearch.DataSource = ds.Tables("tblStaff")
Main.dgSearch.ReadOnly = True

i = ds.Tables("tblClaims").Rows.Count
Main.txtsearchcount.Text = "Found " & i & "Record(s)"


Private Sub dgSearch_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgSearch.CellClick

me.txtstaffFirstName.DataBindings.Add(New Binding("Text", ds, "tblStaff.FirstName"))

end sub



My cat's name is sprinkles
-Ralph Wigam
 
From the looks of it, you're wanting something like what Access gives you when you create an auto-form. The little boxes that automatically display the information based on the location of the current record in the dataset. If this is the case, then you need to set up a CurrencyManager object to handle it. If you do a search, I believe it's been covered before in the forums, if not there's a ton of references on the net if you google "CurrencyManager Visual Basic".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top