Datagridview
-
hi, How to add a blank row in the last index when click on the datagridview. When we type any character in any cell a new blank row is generated by default, likewise i need to generate in any click. AllowUsertoaddrow is set to true. Thankyou
-
hi, How to add a blank row in the last index when click on the datagridview. When we type any character in any cell a new blank row is generated by default, likewise i need to generate in any click. AllowUsertoaddrow is set to true. Thankyou
This will create a new row when the current new row gets clicked. I could see how this may be annoying for users though but I will assume you have your reasons.
public Form1()
{
InitializeComponent();dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1\_CellClick);
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
DataGridView dataGridView = sender as DataGridView;
if(dataGridView.Rows[e.RowIndex].IsNewRow)
{
int newRowIndex = dataGridView.Rows.Add();
dataGridView.CurrentCell = dataGridView.Rows[newRowIndex].Cells[e.ColumnIndex];
}
}