Hide Column Header Only

5 posts, 1 answers
  1. Kaka
    Kaka avatar
    3 posts
    Member since:
    Oct 2014

    Posted 19 Oct 2014 Link to this post

    Hi,

    I want to hide a one header (info header) but not the data like below, is it possible?

    ===============================
    First Name          | Last Name                         --> Header
    ===============================
    First Name 1       | Last Name 1
    ------------------------------------------------------       --> row 1
    Info 1
    ===============================
    First Name 2       | Last Name 2
    ------------------------------------------------------       --> row 2
    Info 2
    ===============================

    Thanks
  2. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 22 Oct 2014 Link to this post

    Hi Kaka, 

    Thank you for contacting us. 

    I am not quite sure what is precisely your case. Can you please provide more information on how are you populating RadGridView, are you using some View Definition and precisely which header you would like to hide.

    In general, you can hide all column headers by setting the ShowColumnHeaders property to false:
    this.radGridView1.ShowColumnHeaders = false;

    I am looking forward to your reply.

    Regards,
    Ralitsa
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Kaka
    Kaka avatar
    3 posts
    Member since:
    Oct 2014

    Posted 22 Oct 2014 in reply to Ralitsa Link to this post

    Hi Ralista,

    Yes I'm using ColumnGroupsViewDefinition.

    ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
     
    view.ColumnGroups.Add(new GridViewColumnGroup("User Details"));
    view.ColumnGroups[1].ShowHeader = false;
     
    view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[1].Rows[0].Columns.Add(radGridView_Main.Columns["FirstName"]);
     
    view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[1].Rows[0].Columns.Add(radGridView_Main.Columns["LastName"]);
     
    view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[1].Rows[1].Columns.Add(radGridView_Main.Columns["Info"]);


    Currently i have this (Current.png), as you can see there is info column. I want to hide the header so it will be like (Result.png).
    Is that possible?

    Thanks,
  5. Answer
    Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 24 Oct 2014 Link to this post

    Hi Kaka, 

    Thank you for your reply and provided images which helped me to understand your case better. 

    You can subscribe to ViewRowFormatting event and set the Visibility property of Info column to Collapsed and change the MinSize property of another 2 columns (FirstName and LastName). You can use the following code snippet: 
    void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
            {
                if (sender is GridHeaderCellElement)
                {
                    if (e.Column.Name == "Title")
                    {
                        e.CellElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
                    }
                    else
                    {
                        e.CellElement.ResetValue(LightVisualElement.VisibilityProperty, Telerik.WinControls.ValueResetFlags.Local);
                    }
     
                    if (e.Column.Name == "FirstName" || e.Column.Name == "LastName")
                    {
                        e.CellElement.MinSize = new Size(0, 57);
                    }
                    else
                    {
                        e.CellElement.ResetValue(LightVisualElement.MinSizeProperty, Telerik.WinControls.ValueResetFlags.Local);
                    }
                }
            }

    I also attached my sample demo project. 

    Should you have further questions, I would be glad to help.

    Regards,
    Ralitsa
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Kaka
    Kaka avatar
    3 posts
    Member since:
    Oct 2014

    Posted 24 Oct 2014 in reply to Ralitsa Link to this post

    Hi Ralitsa,

    Thank you very much, this is what i need.

Back to Top
UI for WinForms is Visual Studio 2017 Ready