This post is continuation to the post which was posted by StatiX on Oct 23rd, 2007 regarding "Get The Selected row in DatagridView". Addition to this post i have a question.
The answer was given by manoshailu as follows:
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick Dim i, j As Integer i = DataGridView1.CurrentRow.Index TextBox1.Text = DataGridView1.Item(0, i).Value TextBox2.Text = DataGridView1.Item(1, i).Value TextBox3.Text = DataGridView1.Item(2, i).Value TextBox4.Text = DataGridView1.Item(3, i).Value End Sub
This answer solved my problem but CANY ANYONE (manoshailu) TELL ME HOW TO ADD SIMILAR CODE FOR "Checkbox"? . I have check box in my form which returns a value "True" and "False" in SQL Database. When i select cell of datagrid the check box doesnt checks in as well as checks out accordingly with the value of datagrid.
My code are as follows:
Private Sub grvDesignationList_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grvDesignationList.CellClick Dim i As Integer i = grvDesignationList.CurrentRow.Index txtDesignationID.Text = grvDesignationList.Item(0, i).Value txtDesignationName.Text = grvDesignationList.Item(1, i).Value txtDesShortName.Text = grvDesignationList.Item(2, i).Value txtDesDescription.Text = grvDesignationList.Item(3, i).Value desDefaultCheckbox.CheckState = grvDesignationList.Item(4, i).Value End Sub
My Code above seems to be not working.