This is a migrated thread and some comments may be shown as answers.

Change type of databound column

2 Answers 165 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gergely
Top achievements
Rank 1
Gergely asked on 30 Dec 2010, 07:42 PM
Hi

I have a RadGridView bound to a object data source. This data source has certain properties with values Y/N. I would like to display the value of this property as a checkbox in the grid. I would like to create the column from source code. Data cannot be edited in the grid in my scenario, the grid is used only to display the data.

I have tried to add a converter to the binding, which has converted Y/N to True/False, but still, the grid view display this as a string, not as a checkbox. Then, I have tried to change the DataType for the column to bool, but the result was only a few empty cells (without the strings or checkboxes). 

My code is the following:
...
new GridViewDataColumn()
{ Header = header,
   DataType=typeof(bool),
   IsAutoGenerated=false,
   DataMemberBinding = new System.Windows.Data.Binding(property.GetMemberName()) { Converter = converter }};

Is there any way to make this work, or what is the easiest way to solve the problem?



Thanks for the help in advance!

Cheers,
             G. M.

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 03 Jan 2011, 08:26 AM
Hi Gergely,

I am sending you a solution utilizing both code-behind and xaml (commented out xaml lines) approach. It is based on changing the CellTemplate property of your column in order to customize the way that it presents your data. It is up to you to choose the approach that fits you better.

Sincerely,
Ivan Ivanov
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Gergely
Top achievements
Rank 1
answered on 03 Jan 2011, 09:42 AM
Well... it seems that is is easier than I thought. Thank you very much for the help, your answer has solved my problem!
Tags
GridView
Asked by
Gergely
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Gergely
Top achievements
Rank 1
Share this question
or