How to pass datagrid data to textbox?

Saravanan07

Newcomer
Joined
May 29, 2009
Messages
1
Hello, I'm currently developing a application in VB.Net. I'm using the DataGridView to display my data on the form and I have stored all the records in MS SQL. I have a EDIT button on the module and I need to know how can I populate a selected record into the textboxes from the DataGridView to be edited. Hope you could understand my question. Thank you very much.

Below are the code and the error are 'CurrentRowIndex' is not a member of 'System.Windows.Forms.DataGridView'.

-
Private Sub cmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEdit.Click
If (gridAdmin.RowCount > 0) Then
If MsgBox("Edit this Administrator Details?", vbExclamation + vbYesNo, "Edit Administrator Details") = vbYes Then
Call drawerOpen()
Call cboOption()
detailbox.Visible = True
cmdUpdate.Visible = True
cmdSave.Visible = False
txtName.ReadOnly = True
txtUsername.ReadOnly = True

txtID.Text = gridAdmin.Rows(gridAdmin.CurrentRowIndex, 0)

End If
Else
dummy = MsgBox("No Administrator Details found!", vbCritical, "Error")
End If
End Sub
 
I think you know the cell the user is standing at the moment he uses the edit button right?, how many rows or columns your datagrid has?
 
Back
Top