You can try this
private void FrmSaveDataFromDataGridView_Load(object sender, EventArgs e)
{
dataGridView1.ColumnCount = 3;
dataGridView1.Columns[0].Name = "Product ID";
dataGridView1.Columns[1].Name = "Product Name";
dataGridView1.Columns[2].Name = "Product Price";
string[] row = new string[] { "1", "Product 1", "1000" };
dataGridView1.Rows.Add(row);
row = new string[] { "2", "Product 2", "2000" };
dataGridView1.Rows.Add(row);
row = new string[] { "3", "Product 3", "3000" };
dataGridView1.Rows.Add(row);
row = new string[] { "4", "Product 4", "4000" };
dataGridView1.Rows.Add(row);
dataGridView1.AllowUserToAddRows = false;
DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
btn.HeaderText = "Update";
dataGridView1.Columns.Add(btn);
btn.UseColumnTextForButtonValue = true;
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
int currentRowIndex = dataGridView1.CurrentCell.RowIndex;
int currentColumnIndex = dataGridView1.CurrentCell.ColumnIndex;
if (currentColumnIndex == dataGridView1.Columns.Count - 1)
{
currentColumnIndex = 0;
string productId = dataGridView1[currentColumnIndex, currentRowIndex].Value.ToString();
currentColumnIndex++;
string productName = dataGridView1[currentColumnIndex, currentRowIndex].Value.ToString();
currentColumnIndex++;
string productPrice = dataGridView1[currentColumnIndex, currentRowIndex].Value.ToString();
currentColumnIndex++;
//HERE YOU CAN WRITE YOUR LOGIC TO SAVE THE DATA IN DATABASE
}
}
above is the sample code in which i have taken one button column in the datagrid view.
Based on that button click i get the data of that particular row in the variables
You can try the above codes
and to enter the data directly in the column you need to double click the particular cell. It will allow you to change the data of that particular cell directly. It does not have any seperate property