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

Dynamic CheckBox header column

4 Answers 102 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aeroth
Top achievements
Rank 1
Aeroth asked on 29 Sep 2011, 02:16 PM
Hi Telerik Support,

I need a CheckBox on my column header for select/unselect all gridview items.
My case is, the RadGridView control is created programmatically and I create a  new class named MyCustomer for RadGridView datasource:

public class MyCutomer
{
    public bool Selected{get;set;}
    public string Name{get;set;}
    public string Company{get;set;}
}
Create RadGridView control:
RadGridView grid = new RadGridView()
{
....
};
 
List<MyCustomer> customers = new List<MyCustomer>();
for( int index=0;index<10;index++)
{
    customers.Add(New MyCustomer()
    {
        ....
    });
}
 
grid.ItemsSource = customers;

All cells of the first column (Selected) are created as a CheckBox but the header is not.
How can I create a CheckBox for my header?

Regards,
Aeroth Lin

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 30 Sep 2011, 07:00 AM
Hello,

 Why not use GridViewSelectColumn directly similar to this demo?

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Aeroth
Top achievements
Rank 1
answered on 02 Oct 2011, 03:53 AM
Hi,

Thanks for the quick response !
I knew that demo but there's no xaml file in my case, I need to insert a GridViewSelectColumn or specify the first column as GridViewSelectColumn dynamically.
All controls on the layout are created dynamically, so I have no xaml files to design my layout at design time.
Any ideas?

Regards,
Aeroth Lin
0
Vlad
Telerik team
answered on 03 Oct 2011, 06:45 AM
Hi,

 You can create the column dynamically and add it to the columns collection.

Best wishes,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Aeroth
Top achievements
Rank 1
answered on 03 Oct 2011, 10:55 AM
Hi,
I forgot to set the SelectionMode(without this column header will be empty):

SelectionMode = System.Windows.Controls.SelectionMode.Extended

It works perfectly now, thanks for your kind help.

Regards,
Aeroth Lin
Tags
GridView
Asked by
Aeroth
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Aeroth
Top achievements
Rank 1
Share this question
or