How to tell a DataGrid to use a customized DataGridTextBoxColumn

J

Jaco Karsten

I am writing a customized DataGrid control which will allow the user to only
select an entire row (and not a cell inside the row). So I want to add
readonly columns to the datagrid. To achieve this, instead of using a
"DataGridTextBoxColumn" inside the datagrid I want the control to use a
"DataGridTextBoxColumn" that has a disabled "Edit" method. Therefor I have
created my own version of a "DataGridTextBoxColumn" class called
"ReadOnlyDataGridTextBox".

How do I get the DataGrid to use my "ReadOnlyDataGridTextBox instead of the
default "DataGridTextBoxColumn"?
 
G

Gawelek

U¿ytkownik "Jaco Karsten said:
I am writing a customized DataGrid control which will allow the user to only
select an entire row (and not a cell inside the row). So I want to add
readonly columns to the datagrid. To achieve this, instead of using a
"DataGridTextBoxColumn" inside the datagrid I want the control to use a
"DataGridTextBoxColumn" that has a disabled "Edit" method. Therefor I have
created my own version of a "DataGridTextBoxColumn" class called
"ReadOnlyDataGridTextBox".

How do I get the DataGrid to use my "ReadOnlyDataGridTextBox instead of the
default "DataGridTextBoxColumn"?


dataGrid1.TableStyles.Add(new DataGridTableStyle());
dataGrid1.TableStyles[0].MappingName = "Table1";
ReadOnlyDataGridTextBox style = new ReadOnlyDataGridTextBox();
style.MappingName = "Kol1";
dataGrid1.TableStyles[0].GridColumnStyles.Clear();
dataGrid1.TableStyles[0].GridColumnStyles.Add(style);


I hope it helps.

Gawel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top