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

Adding a Checkbox column dynamically

6 Answers 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dan Harvey
Top achievements
Rank 2
Dan Harvey asked on 25 May 2010, 03:42 PM
Hello,

I have a radgrid and i have 4 static columns (Name, City, Zip, Country).  I want to add more columns, but i need to add these columns dynamically through code (because the number of columns will change).  I am having trouble figuring this out.  I was hoping there was a "GridViewCheckBoxColumn" like there is a "GridViewComboBoxColumn" but there isn't.  I wasn't able to find anything current in the forums and I was just wondering how to achieve this.  This is the code I have:

 

radGridView1.Columns.Add(new GridViewDataColumn  
 
                                   {  
 
                                        Header = "FullName",  
 
                                        DataMemberBinding = new System.Windows.Data.Binding("FullName")  
 
                                    });  
 
 
//todo: all other columns  
 
int numberOfColumns = 5; //Where 5 is the dynamically changing number  
 
for (var ct = 0; ct < numberOfColumns; ct++)  
 
{  
 
    var cl = new GridViewDataColumn();  
 
    cl.Header = contacts[0].Lists[ct].ListName;  
 
    cl.DataMemberBinding = new System.Windows.Data.Binding("List" + ct);  
 
    radGridView1.Columns.Add(cl);  
 
}  
 

 

Where I'm adding "GridViewDataColumn"'s I would like to add the Checkbox columns instead.
This is what my XAML looks like:
  

 

<UserControl x:Class="RK.CRM.MarketingList.MarketingList.MainPage" 
 
 
 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
 
 
 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
 
 
 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 
 
 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 
 
 
mc:Ignorable="d" 
 
 
 
d:DesignHeight="300" d:DesignWidth="400" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">  
 
 
 
<Grid x:Name="gridMain" Background="White" ShowGridLines="False" Loaded="GridMainLoaded">  
 
 
 
<Grid.RowDefinitions> 
 
 
 
<RowDefinition/> 
 
 
 
<RowDefinition/> 
 
 
 
</Grid.RowDefinitions> 
 
 
 
<Grid.ColumnDefinitions> 
 
 
 
<ColumnDefinition Width="*"/>  
 
 
 
</Grid.ColumnDefinitions> 
 
 
 
<telerik:RadGridView HorizontalAlignment="Left" Margin="24,117,0,0"   
 
Name="radGridView1" VerticalAlignment="Top" Width="800" AutoGenerateColumns="false" /> 
 
 
 
 
</Grid> 
 
</UserControl> 
 

Please advise, thanks!!

 

 

 

6 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 25 May 2010, 03:50 PM
Hi dan harvey,

If the data-bound property is boolean our default column (GridViewdataColumn) will automatically create a CheckBox editors for the respective fields. 

We have also introduced a GridViewCheckBoxColumn with our latest Internal Build from last Friday. If you download this build you should be able to utilize the new built-in column.


Greetings,
Milan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Dan Harvey
Top achievements
Rank 2
answered on 25 May 2010, 04:04 PM
Thank you for your help, it looks like i was using a "ToString()" function on the end of my data that I was binding.
0
Dan Harvey
Top achievements
Rank 2
answered on 25 May 2010, 04:13 PM
I want to try downloading this new internal build...what are the steps to installing this?  Is it documented on the website somewhere?

Thanks,
0
Milan
Telerik team
answered on 25 May 2010, 04:16 PM
Hi dan harvey,

Just login with your account, go to "Your Account", then click Downloads which can be found on the top of the page, find the section related to RadControls for Silverlight, and finally click on Latest Internal Builds link.


Best wishes,
Milan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Dan Harvey
Top achievements
Rank 2
answered on 25 May 2010, 04:19 PM
I should of been more specific, sorry.  I got that far, I downloaded the 00588RadControls_for_Silverlight_4_2010_1_0521_Dev.zip zip file from where you told me to.  Then the documentation i found on the website:

http://www.telerik.com/community/forums/winforms/general-discussions/how-to-install-internal-build.aspx

Tells me that the directions should be included within the zip file.  They are not there.  Do I add the assemblies to the GAC?  What do i do to install these files?

Thanks,
0
Milan
Telerik team
answered on 26 May 2010, 06:38 AM
Hello Dan Harvey,

No need to add those assemblies to GAC. Just extract them somewhere on your machine and reference them from a project.


Kind regards,
Milan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Dan Harvey
Top achievements
Rank 2
Answers by
Milan
Telerik team
Dan Harvey
Top achievements
Rank 2
Share this question
or