I want to enable a specific cell for editing.
My datagridview is readonly false.
and on cell click i get my columnindex and try to do :
if (e.ColumnIndex == 7)
{
if (String.IsNullOrEmpty(Convert.ToString(dgv.Rows[e.RowIndex].Cells["id"].Value)))
{
dgv.Columns[e.ColumnIndex].ReadOnly = true;
}
else
{
dgv.Columns[e.ColumnIndex].ReadOnly = false;
dgv.BeginEdit(true);
dgv.Rows[rowindex].Cells[columnindex].Selected = true;
}
}
without success, my cell stay disable. Could someone help. Thanks
I solved my problem with this code :
private void dgvLocataire_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
dgvLocataire.BeginEdit(false);
var ec = dgvLocataire.EditingControl as DataGridViewComboBoxEditingControl;
if (ec != null && ec.Width - e.X < SystemInformation.VerticalScrollBarWidth)
ec.DroppedDown = true;
if ((e.ColumnIndex != 5) && (e.ColumnIndex != 6) && (e.ColumnIndex != 7))
{
dgvLocataire.Columns[e.ColumnIndex].ReadOnly = true;
}
}
Thanks for your help