jxharding
asked on
prevent a particular datagrid column from being editable - c# sample included from SYNCFUSION
i have a datagridcolumnstyle set up for my datagrid
this is the setup of the datagridcolumn that i do not want editable after it is filled
dim dgcDescription as DataGridTextBoxColumn
datagridtextboxColumn = new datagridtextboxColumn
datagridtextboxColumn.mapp ingName = "Description"
mytablestyles.gridcolumnst yles.add(d atagridtex tboxColumn )
i got the following sample from SYNCFUSION but i dont know how to implement the VB version and where to paste this.
i just need column1 to be non editable
-------------------------- ---------- ---------- ---------- ----------
You can do this by deriving a custom column style and overriding its virtual Edit member. Below is an override that will
prevent the cell in row 1 of the column from getting the edit focus. You can paste this code in the
DataGridDigitsTextBoxColum n sample to see it work.
//this override will prevent the cell in row 1 from getting the edit focus
protected override void Edit(System.Windows.Forms. CurrencyMa nager source, int rowNum, System.Drawing.Rectangle bounds, bool
readOnly, string instantText, bool cellIsVisible)
{
if(rowNum == 1)
return;
base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
}
-------------------------- ---------- ---------- ---------- ----------
could someone please tell me where to paste this and i reckon this.
my datagrid is called dgSale.
it is filled from a dataset.
this is the setup of the datagridcolumn that i do not want editable after it is filled
dim dgcDescription as DataGridTextBoxColumn
datagridtextboxColumn = new datagridtextboxColumn
datagridtextboxColumn.mapp
mytablestyles.gridcolumnst
i got the following sample from SYNCFUSION but i dont know how to implement the VB version and where to paste this.
i just need column1 to be non editable
--------------------------
You can do this by deriving a custom column style and overriding its virtual Edit member. Below is an override that will
prevent the cell in row 1 of the column from getting the edit focus. You can paste this code in the
DataGridDigitsTextBoxColum
//this override will prevent the cell in row 1 from getting the edit focus
protected override void Edit(System.Windows.Forms.
readOnly, string instantText, bool cellIsVisible)
{
if(rowNum == 1)
return;
base.Edit(source, rowNum, bounds, readOnly, instantText, cellIsVisible);
}
--------------------------
could someone please tell me where to paste this and i reckon this.
my datagrid is called dgSale.
it is filled from a dataset.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You need to create a new class which inherits from datagridtextboxColumn and paste the above code in your new class
if you need a code example let me know
if you need a code example let me know
ASKER
i thought there was i shorter way maybe just using that little section of code. ill just use the sample from SYNCFUSION
thanks!
thanks!
ASKER
would still like to know where to paste the code if someone has an answer.
thank you!