Hello All Experts,
I have one textbox, if suppose if i type anything in that textbox then its should automatically comes to DataGridView particular cell.
Can any one have the code for doing this stuff?
Regards,
AKM
Printable View
Hello All Experts,
I have one textbox, if suppose if i type anything in that textbox then its should automatically comes to DataGridView particular cell.
Can any one have the code for doing this stuff?
Regards,
AKM
Hello.
You just need to know the Row and Column number of the particular cell you'd like the text to be enetered.
If I were to do this :
It will enter TextBox1's text in the first column of the first row; TextBox2's text into the second column of the first row, and TextBox3's text into the third column of the first row.Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataGridView1.Rows(0).Cells(0).Value = TextBox1.Text 'Enter in 1st Row 1st Col
DataGridView1.Rows(0).Cells(1).Value = TextBox2.Text 'Enter in 1st Row 2nd Col
DataGridView1.Rows(0).Cells(2).Value = TextBox3.Text 'Enter in 1st Row 3rd Col
End Sub
EDIT: You mentioned "automatically". Do you want this text to appear as you are busy typing into the TextBox? I'd then suggest the Change event, but, the proper advice would be to use either the LostFocus or Leave events. The reason why I say so is that you have to think about validating the entered contents.
I hope it helps! :)
Hannes
Please note that this logic only apply to first row, not the particular row which i have selected by below coding logic.
Above logic is like that if i select any row in DataGridview its displaying its value in Texboxes.Code:Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
DocEntry.Text = DataGridView1.Rows(e.RowIndex).Cells("DocEntry").Value
CardNameEdit.Text = DataGridView1.Rows(e.RowIndex).Cells("CardName").Value
CardSerialEdit.Text = DataGridView1.Rows(e.RowIndex).Cells("CardSerialNo").Value
CustName.Text = DataGridView1.Rows(e.RowIndex).Cells("CustomerName").Value
Branch.Text = DataGridView1.Rows(e.RowIndex).Cells("BranchName").Value
CardStatus.Text = DataGridView1.Rows(e.RowIndex).Cells("CardStatus").Value
End Sub
Now what i want if i change that anytextbox value then its automatically comes to datagridview
and the Datagridrow status should be in update mode.
Regards,
AKM