I was able to do something like this by creating my own
column style and overriding the Edit method. See below:
public class DataGridReadOnlyTextBoxColumn :
DataGridTextBoxColumn
{
private int m_ReadOnlyRow;
public int intReadOnlyRow {
get{return this.m_ReadOnlyRow;}
set{this.m_ReadOnlyRow = value;}
}
//this override will prevent the cell in row
m_ReadOnlyRow from getting the edit focus
protected override void Edit
(System.Windows.Forms.CurrencyManager source, int rowNum,
System.Drawing.Rectangle bounds, bool readOnly, string
instantText, bool cellIsVisible) {
if(rowNum == this.m_ReadOnlyRow)
return;
base.Edit(source, rowNum, bounds,
readOnly, instantText, cellIsVisible);
}
}
Hope this helps.
-----Original Message-----
I have a windows forms data grid where I want to disallow the editing of
certain cells. At the moment though I can't get any code to trigger,
whether I include it in any of the
DataGrid_KeyDown/Up/Press events.