/// <summary>
/// 编辑单元格控件时发生的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgv_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dgv.CurrentCell.ColumnIndex == 1 ||dgv.CurrentCell.ColumnIndex==2||dgv.CurrentCell.ColumnIndex == 4)//指定列
{
if (e.Control.GetType().ToString().Equals("System.Windows.Forms.DataGridViewTextBoxEditingControl"))
{
((DataGridViewTextBoxEditingControl)e.Control).ReadOnly = true; //不可编辑
}
else
{
((DataGridViewTextBoxEditingControl)e.Control).ReadOnly = false;//可编辑
}
}
else
{
((DataGridViewTextBoxEditingControl)e.Control).ReadOnly = false;//可编辑
}
}
/// 编辑单元格控件时发生的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgv_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dgv.CurrentCell.ColumnIndex == 1 ||dgv.CurrentCell.ColumnIndex==2||dgv.CurrentCell.ColumnIndex == 4)//指定列
{
if (e.Control.GetType().ToString().Equals("System.Windows.Forms.DataGridViewTextBoxEditingControl"))
{
((DataGridViewTextBoxEditingControl)e.Control).ReadOnly = true; //不可编辑
}
else
{
((DataGridViewTextBoxEditingControl)e.Control).ReadOnly = false;//可编辑
}
}
else
{
((DataGridViewTextBoxEditingControl)e.Control).ReadOnly = false;//可编辑
}
}