ColumnGroupsViewDefinition Header Height

16 posts, 0 answers
  1. Bill
    Bill avatar
    27 posts
    Member since:
    Oct 2008

    Posted 06 Feb 2009 Link to this post

    How can I can I make second row of headings taller when I use the ColumnGroupsViewDefinition?

    I've tried ...
    grd.GridElement.TableHeaderHeight = 100;  
     
    ...and also setting the row height in the group rows...
    ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();  
    view.ColumnGroups.Add(new GridViewColumnGroup("Vendor"));  
    view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());  
    view.ColumnGroups[0].Rows[0].Height = 100;  
     
    Niether seem to have any effect.


    My heading text also has newlines in it (E.g. "Profit\nMargin")
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 09 Feb 2009 Link to this post

    Hi Bill,

    Thank you for writing. Currently the Height property of GridViewColumnGroupRow is ignored. You can use the RowSpan property of GridViewColumn instead. Here is sample code:

     
    view.ColumnGroups[0].Rows[0].Columns[0].RowSpan = 100; 
     

    The TableHeaderHeight is not used when using the ColumnGroupsViewDefinition. We plan to improve our API and address the issues in one of our upcoming releases this year.

    Do not hesitate to write me back if you have more questions.

    Regards,
    Jack
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Bill
    Bill avatar
    27 posts
    Member since:
    Oct 2008

    Posted 09 Feb 2009 Link to this post

    Working well. Thank you...
  4. Bill
    Bill avatar
    27 posts
    Member since:
    Oct 2008

    Posted 09 Feb 2009 Link to this post

    Rats, I mispoke.  The heading row did get taller but now it looks like the data rows are taller too.  I only want the headings tall.  How can I make the headings tall without the data rows below getting taller?
  5. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 10 Feb 2009 Link to this post

    Hello Bill,

    In column groups view mode, the height of the column headers row is synchronized with the height of all other rows. We will consider changing this behavior in one of our upcoming releases in order to enable the requested functionality.

    You should iterate through all rows and set their height manually to work around the issue. Take a look at this code:

    foreach (GridViewDataRowInfo row in this.radGridView1.Rows) 
        row.Height = 20; 

    Do not hesitate to write us if you need further assistance.

    All the best,
    Jack
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Celeste Zietsman
    Celeste Zietsman avatar
    17 posts
    Member since:
    Apr 2010

    Posted 08 Dec 2010 Link to this post

    Hi Jack

    I have the same problem. I'm using version 2010_03_10_1109. I used the work around that you posted but it takes a while for the form to load. Has there been any changes for this in the newer versions?

    Thanks
    Celeste
  7. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 08 Dec 2010 Link to this post

    Hello Celeste,

    Try wrapping Jack's solution using
    radGridView1.BeginUpdate();
    // do something
    radGridView1.EndUpdate();
     
    // or
     
    using (radGridView1.DeferRefresh())
    {
    // do something
    }

    Thus preventing the grid from refreshing on each row height change.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  8. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 11 Dec 2010 Link to this post

    Hi Celeste Veotte,

    Besides the solutions that Emanuel suggested you can initialize the MinHeight property when handling the CreateRowInfo event which we added in Q3 2010. Consider the code snippet below:
    this.radGridView1.MasterTemplate.CreateRowInfo += new GridViewCreateRowInfoEventHandler(MasterTemplate_CreateRowInfo);
     
    void MasterTemplate_CreateRowInfo(object sender, GridViewCreateRowInfoEventArgs e)
    {
        e.RowInfo.SuspendPropertyNotifications();
        e.RowInfo.MinHeight = 25;
        e.RowInfo.ResumePropertyNotifications();
    }

    I hope this helps.

    Greetings,
    Jack
    the Telerik team
    Get started with RadControls for WinForms with numerous videos and detailed documentation.
  9. John
    John avatar
    28 posts
    Member since:
    Sep 2013

    Posted 25 Apr 2018 Link to this post

    Hi,

    Has there been any update on this issue in the past 7 years - setting the height of the column headers when using ColumnGroupsViewDefinitions?

    Thanks,

    John

     

  10. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4130 posts

    Posted 26 Apr 2018 Link to this post

    Hello, John,   

    You can manipulate the height of the column group headers by setting the RowSpan property. Here is a sample code snippet which result is illustrated in the below screenshot. The Details group is 100 px high and the Address group is 50 px high.

    ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
    view.ColumnGroups.Add(new GridViewColumnGroup("Customer Contact"));
    view.ColumnGroups.Add(new GridViewColumnGroup("Details"));
    view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Address"));
    view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Contact"));
    view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[0].Rows[0].ColumnNames.Add("CompanyName");
    view.ColumnGroups[0].Rows[0].ColumnNames.Add("ContactName");
    view.ColumnGroups[0].Rows[0].ColumnNames.Add("ContactTitle");
    view.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[1].Groups[0].Rows[0].ColumnNames.Add("Address");
    view.ColumnGroups[1].Groups[0].Rows[0].ColumnNames.Add("City");
    view.ColumnGroups[1].Groups[0].Rows[0].ColumnNames.Add("Country");
    view.ColumnGroups[1].Groups[1].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[1].Groups[1].Rows[0].ColumnNames.Add("Phone");
    view.ColumnGroups[1].Groups[1].Rows[0].ColumnNames.Add("Fax");
     
    view.ColumnGroups[1].RowSpan = 100;
    view.ColumnGroups[1].Groups[0].RowSpan = 50;
    radGridView1.ViewDefinition = view;



    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  11. John
    John avatar
    28 posts
    Member since:
    Sep 2013

    Posted 26 Apr 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hi Dess,  

    How can I change the height of the Row, where all the column names are displayed (Company Name, Address, etc.).

    Thanks,

    John

     

  12. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4130 posts

    Posted 30 Apr 2018 Link to this post

    Hello, John,   

    In order to change the height of the header row you can specify the MinHeight property of the respective GridViewColumnGroupRow in the GridViewColumnGroup:
    view.ColumnGroups[0].Rows[0].MinHeight = 30;
     
    radGridView1.ViewDefinition = view;



    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  13. Dilshod
    Dilshod avatar
    16 posts
    Member since:
    Mar 2011

    Posted 01 Jul 2018 Link to this post

    Hello,

    Setting a value to RowSpan property is not working if grid AutoRowSize = true. Any solution?

     

  14. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4130 posts

    Posted 02 Jul 2018 Link to this post

    Hello, Dilshod,    

    When the AutoRowSize property is set to true, the rows in RadGridView are sized according to the content they have. That is why properties that affect the row's height are not respected in this case. 

    I hope this information helps. If you have any additional questions, please let me know. 
     
     
    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  15. Dilshod
    Dilshod avatar
    16 posts
    Member since:
    Mar 2011

    Posted 02 Jul 2018 Link to this post

    Hello Dess,

    So, in order to set RowSpan manually, I have to set AutoRowSize property to false. But then, how to calculate the height of the data rows where two or more lines of text?

  16. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4130 posts

    Posted 03 Jul 2018 Link to this post

    Hello, Dilshod,    

    You can iterate all columns in RadGridView and set the GridViewColumn.WrapText property to true. Thus, the cell values will be wrapped. In addition, you can use the demonstrated approach in the following help article showing how to autosize the entire row by measuring the content. For this purpose it is necessary to create a custom GridDataRowElement: https://docs.telerik.com/devtools/winforms/gridview/rows/how-to/autosize-entire-row
     
    As a result, you will have the desired minimum height for the headers in the ColumnGroupsViewDefinition and autosize the data rows as it is illustrated in the screenshot.

     

    Here is a complete code snippet: 

    public RadForm1()
    {
        InitializeComponent();
     
        this.radGridView1.CreateRow += radGridView1_CreateRow;
     
        foreach (GridViewColumn col in this.radGridView1.Columns)
        {
            col.WrapText = true;
        }
    }
     
    private void radGridView1_CreateRow(object sender, GridViewCreateRowEventArgs e)
    {
        if (e.RowType == typeof(GridDataRowElement))
        {
            e.RowType = typeof(CustomRowElement);
        }
    }
     
    private void RadForm1_Load(object sender, EventArgs e)
    {
        this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
     
        ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
        view.ColumnGroups.Add(new GridViewColumnGroup("Customer Contact"));
        view.ColumnGroups.Add(new GridViewColumnGroup("Details"));
        view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Address"));
        view.ColumnGroups[1].Groups.Add(new GridViewColumnGroup("Contact"));
        view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
        view.ColumnGroups[0].Rows[0].ColumnNames.Add("CompanyName");
        view.ColumnGroups[0].Rows[0].ColumnNames.Add("ContactName");
        view.ColumnGroups[0].Rows[0].ColumnNames.Add("ContactTitle");
        view.ColumnGroups[1].Groups[0].Rows.Add(new GridViewColumnGroupRow());
        view.ColumnGroups[1].Groups[0].Rows[0].ColumnNames.Add("Address");
        view.ColumnGroups[1].Groups[0].Rows[0].ColumnNames.Add("City");
        view.ColumnGroups[1].Groups[0].Rows[0].ColumnNames.Add("Country");
        view.ColumnGroups[1].Groups[1].Rows.Add(new GridViewColumnGroupRow());
        view.ColumnGroups[1].Groups[1].Rows[0].ColumnNames.Add("Phone");
        view.ColumnGroups[1].Groups[1].Rows[0].ColumnNames.Add("Fax");
         
        view.ColumnGroups[1].RowSpan = 100;
         
        view.ColumnGroups[1].Groups[0].RowSpan = 50;
        view.ColumnGroups[0].Rows[0].MinHeight = 30;
     
        radGridView1.ViewDefinition = view;
    }
     
    public class CustomRowElement : GridDataRowElement
    {
        protected override Type ThemeEffectiveType
        {
            get
            {
                return typeof(GridDataRowElement);
            }
        }
     
        protected override SizeF MeasureOverride(SizeF availableSize)
        {
            SizeF baseSize = base.MeasureOverride(availableSize);
            CellElementProvider provider = new CellElementProvider(this.TableElement);
            SizeF desiredSize = SizeF.Empty;
            foreach (GridViewColumn column in this.ViewTemplate.Columns)
            {
                if (!this.IsColumnVisible(column))
                {
                    continue;
                }
                GridDataCellElement cellElement = provider.GetElement(column, this) as GridDataCellElement;
                this.Children.Add(cellElement);
                if (cellElement != null)
                {
                    cellElement.Measure(new SizeF(column.Width, float.PositiveInfinity));
                    if (desiredSize.Height < cellElement.DesiredSize.Height)
                    {
                        desiredSize.Height = cellElement.DesiredSize.Height;
                    }
                }
                cellElement.Detach();
                this.Children.Remove(cellElement);
            }
            SizeF elementSize = this.TableElement.RowScroller.ElementProvider.GetElementSize(this.RowInfo);
            int oldHeight = RowInfo.Height == -1 ? (int)elementSize.Height : RowInfo.Height;
            this.RowInfo.SuspendPropertyNotifications();
            this.RowInfo.Height = (int)desiredSize.Height;
            this.RowInfo.ResumePropertyNotifications();
            if (!this.RowInfo.IsPinned)
            {
                int delta = RowInfo.Height - oldHeight;
                TableElement.RowScroller.UpdateScrollRange(TableElement.RowScroller.Scrollbar.Maximum + delta, false);
            }
            baseSize.Height = this.RowInfo.Height;
            return baseSize;
        }
     
        private bool IsColumnVisible(GridViewColumn column)
        {
            return column.IsVisible;
        }
    }

    I hope this information helps. If you have any additional questions, please let me know. 
     
    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top