简体   繁体   English

如何在C#中的devexpress的datagridview中使特定列可编辑以进行复制?

[英]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. 一种解决方案是更改列的ReadOnlyAllowEdit选项。

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.

相关问题 在datagridview中使一个单元格可编辑c# - Make one cell editable in datagridview c# 如何使用C#在datagridview中创建唯一列? - How to make a unique column in datagridview with c#? 如何在DataGridView C#中合并特定的列标题? - How can merge a particular column header in DataGridView C#? C# - DevExpress - GridControl - DataGridView - C# - DevExpress - GridControl - DataGridView C# GUI 可编辑 DataGridView - C# GUI Editable DataGridView C#DevExpress GridControl:如何根据特定的列文本进行搜索 - C# DevExpress GridControl : how to make search according to specific column text 如何在C#Windows应用程序中将选中的列表框的选定项添加到datagridview中的特定列? - how can i get the selected items of a checked listbox to a particular column in datagridview in c# windows application? 如何遍历/循环遍历C#WinForm应用程序中的DevExpress.GridView.gridcontrol的特定列的每个单元格? - How to traverse/loop through each cell of particular COLUMN of DevExpress.GridView.gridcontrol in C# WinForm Application..? C#-如何将在DataGridView中搜索的行复制到新的DataGridView - C# - How To Copy The Searched Rows In DataGridView To New DataGridView C#DataGridView DataGridViewTextCell到DataGridViewComboBoxCell可编辑文本 - C# DataGridView DataGridViewTextCell to DataGridViewComboBoxCell editable text
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM