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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass Value of Textbox to Grid

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
US
I have a simple datagridview. I'm trying to set up the form to where a user can type something into a textbox and it fills up an entire column of the grid. I want a textbox above a column and whatever gets typed into that textbox would flow down that column regardless of how many rows.

Any help would be appreciated


 
This is what I came up with so far. the part I can't figure out is how to get all the rows to update if there are more then one row.

With dg1
.Rows(0).Cells("Name").Value = txt1.Text
End With

 
Let's say you want the text from your txt1 in second column in your grid dg1:

Code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
                     ByVal e As System.EventArgs) _
                     Handles txt1.TextChanged

    For r As Integer = 0 To dg1.Rows.Count - 1
        dg1.Item(1, r).Value = txt1.Text
    Next

End Sub

Have fun.

---- Andy
 
Thank you...

Now I'm trying to save the data using the below code. the data is saved except for the first row.

For r As Integer = 0 To dg1.Rows.Count - 1
dg1.Item(8, r).Value = "N"
Next

sAdapter.Update(sDs, "TableName")
sDs.AcceptChanges()
MsgBox("Your Changes Have Been Saved")

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top