[英]how to make particular column editable for copy in datagridview of devexpress in c#?
我有devexpress datagridview有10列与第一列作为名称,这是不可编辑的,但用户应该能够复制单元格content(Name)。
private void gridViewBatches_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e)
{
GridView view = sender as GridView;
if (view.FocusedColumn.FieldName == "Batch No") //Editable true
{
e.Cancel = false;
} else //Other column editble false
{
e.Cancel = true;
}
}
One solution is to change ReadOnly
or AllowEdit
options of your columns. 一种解决方案是更改列的ReadOnly
或AllowEdit
选项。
Other solution is to use the ShowingEditor
event of the view and disable cell editing via code using the event handler's e.Cancel
parameter. 其他解决方案是使用视图的ShowingEditor
事件,并使用事件处理程序的e.Cancel
参数通过代码禁用单元格编辑。
Here is the code snippet: 这是代码片段:
//Disable updating on the entire grid
uGrid1.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.False;
// Disable the first column in the first band
ultraGrid1.DisplayLayout.Bands[0].Columns[0].CellActivation = Activation.Disabled;
// Disable the first cell in the grid
uGrid1.Rows[0].Cells[0].Activation = Activation.Disabled;
ultraGrid1.DisplayLayout.Bands[0].Columns[0].CellActivation = Activation.Disabled;
Update : 更新:
Following solution works for Amol as confirmed in comments, including here for others benefit. 评论中确认的以下解决方案适用于Amol,包括此处的其他收益。
private void gridViewBatches_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e)
{
GridView view = sender as GridView;
if (view.FocusedColumn.FieldName == "Batch No") //Editable true
{
e.Cancel = false;
} else //Other column editble false
{
e.Cancel = true;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.