1

選択モードをに設定して Sourcegrid.DataGrid を使用しています

this.dataGrid1.SelectionMode = SourceGrid.GridSelectionMode.Row;

単一のセルの編集を (ダブルクリックで) 無効にする必要があります。

を使用して列全体を無効にする方法を知っています

this.dataGrid1.Columns[0].DataCell.Editor.EnableEdit = false;

しかし、単一のセルを無効にする方法がわかりません。

誰かがその方法を説明できますか?

4

1 に答える 1

1

マレクの努力に感謝しますが、あなたの解決策は別の .net コントロールです。

問題を解決するための回避策を見つけました。単一のセルを無効にすることを回避するコントロールにバグがあると思います (または、これを行うための適切な解決策が見つかりませんでした)。

固定/事前定義されたテキストを含むセルがある場合、次のコードで編集をブロックできます

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
}

これが誰かを助けることができることを願っています。

よろしく、
アレックス

于 2013-07-19T13:55:01.763 に答える