0
Answer

How to save the changed value of DataGrid cell into a string

Akash Pal

Akash Pal

9y
412
1
private void label5_Click(object sender, EventArgs e)
{


int rowIndex = dataGridView1.CurrentCell.RowIndex;

int columnIndex = dataGridView1.CurrentCell.ColumnIndex;

string ColumnName = dataGridView1.Columns[columnIndex].Name;
string NewValue = dataGridView1.Rows[rowIndex].Cells[columnIndex].FormattedValue.ToString();
MessageBox.Show(dataGridView1.CurrentCell.Value.ToString());

global.EditBook(columnIndex, rowIndex, ColumnName, NewValue);
DataTable dt = global.filldata();
dataGridView1.DataSource=dt;
pictureBox7.Visible = true;
MessageBox.Show(dataGridView1.Columns[columnIndex].Name.ToString());
}