Dynamic CheckBox header column

5 posts, 0 answers
  1. Aeroth
    Aeroth avatar
    17 posts
    Member since:
    Oct 2010

    Posted 29 Sep 2011 Link to this post

    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
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 30 Sep 2011 Link to this post

    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 >>

  3. Aeroth
    Aeroth avatar
    17 posts
    Member since:
    Oct 2010

    Posted 01 Oct 2011 Link to this post

    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
  4. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 03 Oct 2011 Link to this post

    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 >>

  5. Aeroth
    Aeroth avatar
    17 posts
    Member since:
    Oct 2010

    Posted 03 Oct 2011 Link to this post

    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
Back to Top