In Windows Forms DataGridView, How Can I Delete the values of selected cells through drag?
Multiselect is applied as true in datagridview But I don't know how to delete dragged cells.
private void DataGridView1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Delete:
if (dataGridView1.Focused == true)
{
dataGridView1.CurrentCell.Value = "";
dataGridView1.EndEdit();
//MultiSelect Cell Delete All Cells(Drag)
}
else if (dataGridView2.Focused == true)
{
dataGridView2.CurrentCell.Value = "";
dataGridView2.EndEdit();
}
break;
case Keys.Back:
if (dataGridView1.Focused == true)
{
dataGridView1.CurrentCell.Value = "";
dataGridView1.EndEdit();
}
else if (dataGridView2.Focused == true)
{
dataGridView2.CurrentCell.Value = "";
dataGridView2.EndEdit();
}
break;
}
}