i have a datagridview with 2 columns on it.
i add column 1 manually from Datagridview task (add columns), it should numeric value and came from user input.
for column 2 (it's numeric value), on load event from database with this :
Using conn As New MySqlConnection("connection string") conn.Open() Dim command As New MySqlCommand("select amount from my_tabel_in_database", conn) Dim adapter As New MySqlDataAdapter Dim dt As New DataTable adapter.SelectCommand = command adapter.Fill(dt) DataGridView1.DataSource = dt adapter.Dispose() command.Dispose() conn.Close() Dim total1, total2 As Double For i As Integer = 0 To DataGridView1.Rows.Count - 1 total1 += DataGridView1.Rows(i).Cells(0).Value total2 += DataGridView1.Rows(i).Cells(1).Value Next Dim myrow = dt.NewRow myrow(0) = total1 myrow(1) = total2 dt.Rows.Add() dt.Rows.Add(myrow) End Using
my purpose is to add total1 and total2 in bottom of that both column, but i get this error :
Cannot find Column 1
how to insert that both total in the bottom of column?