【问题标题】:Xtragrid one column editable other aren'tXtragrid 一列可编辑,其他不可编辑
【发布时间】:2013-10-30 05:57:17
【问题描述】:

您好,我有 DevExpress xtragrid 控件。如何只设置一列editable = true(列为空)

【问题讨论】:

    标签: c# devexpress xtragrid


    【解决方案1】:

    使用GridColumn.OptionsColumn.AllowEdit 属性:

    // sample data
    gridControl1.DataSource = new List<DataObj> { 
        new DataObj(){ Agent = "AMD" },
        new DataObj(){ Agent = "!!!AMD" },
    };
    //...
    gridView1.PopulateColumns();
    foreach(GridColumn column in gridView1.Columns) // disable editing for all columns
        column.OptionsColumn.AllowEdit = false;
    gridView1.Columns["Description"].OptionsColumn.AllowEdit = true; // enable editing for specific column
    //...
    class DataObj {
        public string Agent { get; set; }
        public string Description { get; set; }
    }
    

    【讨论】:

      【解决方案2】:

      @DmitryG 的答案是正确的,如果您需要从代码中自动处理所有列。

      如果您不想从代码中更改它(代码将添加到 *designer.cs 文件中): 转到xtragrid的设计器->列 对于您希望不可编辑的每一列,选择列选项并选择“true”表示只读或“false”允许编辑。

      http://documentation.devexpress.com/#WindowsForms/CustomDocument807

      【讨论】:

        【解决方案3】:

        您的问题有点模糊,如果您想将列设置为只读,请执行以下操作;

        YourcolName.OptionsColumn.AllowEdit = false;
        

        如果您的列不可编辑,那么问题出在您的数据源上,也可能是列表实现。或保存您的行数据的对象,或者您正在尝试更新未绑定的行?

        您必须提供更多信息,我们才能给您任何答案...

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2013-05-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-05-25
          相关资源
          最近更新 更多