how do i say that if you click any cell in a datagridview, then i want to assign a variable like 'a' the value of the 3rd column in the datagridview
thanks
thanks
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Me.MarksTableAdapter.FillBy2(Me.Database1DataSet21.Marks, txtSearch.Text) Catch ex As System.Exception System.Windows.Forms.MessageBox.Show(ex.Message) End Try Button1.Visible = False Dim h As Integer h = DataGridView2.Columns(2).Index Dim a As Integer a = DataGridView2.Item(h, 0).Value Dim b As Integer b = DataGridView2.Item(h, 1).Value Dim c As Integer c = DataGridView2.Item(h, 2).Value If DataGridView2.Rows(3).Index = False Then Exit Sub End If Dim d As Integer d = DataGridView2.Item(h, 3).Value txtAverage.Text = (a + b + c + d) / (DataGridView2.RowCount - 1) End Sub
Comment