Dear All,
Please kindly help me, i go data in the datagridview and textbox from database. i would like in textbox data change and equal to rows of datagridview. when i click next or previous button.
Thanks in advance.
Chantra
Dear All,
Please kindly help me, i go data in the datagridview and textbox from database. i would like in textbox data change and equal to rows of datagridview. when i click next or previous button.
Thanks in advance.
Chantra
the following code is working if the datagridview properties are set as follow:
Multiselect = false
SelectionMode = FullRowSelect
Private Sub DataGridView1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
Try
TextBox1.Text = DataGridView1.SelectedRows(0).Cells(1).Value
Catch ex As Exception
'catch exception while filling the DGV
End Try
End Sub
Private Sub backButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles backButton.Click
Try
Dim currentRow As Integer = DataGridView1.SelectedRows(0).Index
DataGridView1.Rows(currentRow - 1).Selected = True
Catch ex As Exception
'catch if currentRow is first row
End Try
End Sub
Private Sub forwardButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles forwardButton.Click
Try
Dim currentRow As Integer = DataGridView1.SelectedRows(0).Index
DataGridView1.Rows(currentRow + 1).Selected = True
Catch ex As Exception
'catch if currentRow is last row
End Try
End Sub
the following code is working if the datagridview properties are set as follow:
Multiselect = false
SelectionMode = FullRowSelectPrivate Sub DataGridView1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged Try TextBox1.Text = DataGridView1.SelectedRows(0).Cells(1).Value Catch ex As Exception 'catch exception while filling the DGV End Try End Sub Private Sub backButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles backButton.Click Try Dim currentRow As Integer = DataGridView1.SelectedRows(0).Index DataGridView1.Rows(currentRow - 1).Selected = True Catch ex As Exception 'catch if currentRow is first row End Try End Sub Private Sub forwardButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles forwardButton.Click Try Dim currentRow As Integer = DataGridView1.SelectedRows(0).Index DataGridView1.Rows(currentRow + 1).Selected = True Catch ex As Exception 'catch if currentRow is last row End Try End Sub
Thank you very much for your advice. i do it work as well.
again, i would like to right of record of datagridview in each rows showing icon or picture with different(one rows one picture and other one more picture. i got three of icon. it is regarding select of database table.
Please advice.
Thank!
Chantra
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.