C# SourceGrid:如何禁用单个单元格?

C# SourceGrid:如何禁用单个单元格?,c#,.net,datagrid,C#,.net,Datagrid,我正在使用选择模式设置为的Sourcegrid.DataGrid this.dataGrid1.SelectionMode = SourceGrid.GridSelectionMode.Row; 我需要禁用编辑(双击)单个单元格 我知道如何使用禁用整个列 this.dataGrid1.Columns[0].DataCell.Editor.EnableEdit = false; 但我不知道如何禁用单个单元格 有人能解释一下怎么做吗?谢谢您的努力,但您的解决方案是另一个.net控件 我已经找到了

我正在使用选择模式设置为的Sourcegrid.DataGrid

this.dataGrid1.SelectionMode = SourceGrid.GridSelectionMode.Row;
我需要禁用编辑(双击)单个单元格

我知道如何使用禁用整个列

this.dataGrid1.Columns[0].DataCell.Editor.EnableEdit = false;
但我不知道如何禁用单个单元格


有人能解释一下怎么做吗?

谢谢您的努力,但您的解决方案是另一个.net控件

我已经找到了解决这个问题的办法。我认为控件上有一个bug,可以避免禁用单个单元格(或者我还没有找到正确的解决方案)

如果我有一个带有固定/预定义文本的单元格,我可以使用以下代码阻止编辑

private void dataGrid1_DoubleClick(object sender, EventArgs e)
{
    SourceGrid.DataGrid dg = (SourceGrid.DataGrid)sender;
    //Get the position of the clicked cell
    int c = dg.MouseCellPosition.Column;
    int r = dg.MouseCellPosition.Row;
    //create a Cell context 
    SourceGrid.CellContext cc = new SourceGrid.CellContext(dg, new SourceGrid.Position(r,c));
    //and retrieve the value to be compared with a pre-defined text
    if (String.Compare(cc.DisplayText, "SOMETEXT") == 0)
        this.dataGrid1.GetCell(r, c).Editor.EnableEdit = false; //Disable the editing 
    else
        this.dataGrid1.GetCell(r, c).Editor.EnableEdit = true;  //Enable the editing
}
我希望这能帮助别人

问候,

Alex

感谢Marek的努力,但您的解决方案是另一个.net控件

我已经找到了解决这个问题的办法。我认为控件上有一个bug,可以避免禁用单个单元格(或者我还没有找到正确的解决方案)

如果我有一个带有固定/预定义文本的单元格,我可以使用以下代码阻止编辑

private void dataGrid1_DoubleClick(object sender, EventArgs e)
{
    SourceGrid.DataGrid dg = (SourceGrid.DataGrid)sender;
    //Get the position of the clicked cell
    int c = dg.MouseCellPosition.Column;
    int r = dg.MouseCellPosition.Row;
    //create a Cell context 
    SourceGrid.CellContext cc = new SourceGrid.CellContext(dg, new SourceGrid.Position(r,c));
    //and retrieve the value to be compared with a pre-defined text
    if (String.Compare(cc.DisplayText, "SOMETEXT") == 0)
        this.dataGrid1.GetCell(r, c).Editor.EnableEdit = false; //Disable the editing 
    else
        this.dataGrid1.GetCell(r, c).Editor.EnableEdit = true;  //Enable the editing
}
我希望这能帮助别人

问候,
亚历克斯