ユーザーが特定の dgvRow でセルを選択できないようにする方法はありますか。
行は読み取り専用ですが、それでも選択可能です。
1 に答える
            2        
        
		
選択が変更されるたびに問題のセルの選択を解除するカスタム デリゲートを追加できます。
DataGridView1.SelectionChanged += new EventHandler(DataGridView1_SelectionChanged);
private void DataGridView1_SelectionChanged(object sender, EventArgs e){
    List<DataGridViewCell> toBeRemoved = new List<DataGridViewCell>();
    foreach(DataGridViewCell selectedCell in DataGridView1.SelectedCells){
        if (isCellUnSelectable(selectedCell))
            toBeRemoved.Add(selectedCell);
    }
    foreach(DataGridViewCell cell in toBeRemoved){
        cell.Selected = false;
    }
}
    于 2012-06-06T20:56:15.290   に答える