Multiple lines of text in ColumnGroup header

7 posts, 1 answers
  1. Karl
    Karl avatar
    35 posts
    Member since:
    Dec 2013

    Posted 25 Jan Link to this post

    How can I display multiple lines of text in a column group header?  I can't see my "Line2" text in the sample below

     

    public Form1()
        {
        InitializeComponent();
     
        ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
     
        List<String> cols = new List<string> () {"column2", "column3"};
        view.ColumnGroups.Add (CreateColGroup (cols, "Customer Contact"));
     
        view.ColumnGroups.Add(CreateColGroup(new List<string> (){"DNE", "column1"}, ""));
        this.radGridView1.ViewDefinition = view;
        }
     
    private GridViewColumnGroup CreateColGroup (List<string> cols, string  groupName)
        {
        var colGroup = new GridViewColumnGroup(groupName);
        var groupRow = new GridViewColumnGroupRow();
        foreach (var colName in cols)
            {
            if (this.radGridView1.Columns[colName] != null)
                {
                groupRow.Columns.Add (this.radGridView1.Columns[colName]);
                }
            }
     
        foreach (var col in groupRow.Columns)
            {
            col.HeaderText += "\n  Line2";
            }
     
        colGroup.Rows.Add(groupRow);
     
        return colGroup;
        }

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 26 Jan Link to this post

    Hello Karl,

    Thank you for writing.

    You can set the MinHeight of the group row:
    private GridViewColumnGroup CreateColGroup(List<string> cols, string groupName)
    {
        var colGroup = new GridViewColumnGroup(groupName);
        var groupRow = new GridViewColumnGroupRow();
        foreach (var colName in cols)
        {
            if (this.radGridView1.Columns[colName] != null)
            {
                groupRow.Columns.Add(this.radGridView1.Columns[colName]);
            }
        }
     
        foreach (var col in groupRow.Columns)
        {
            col.HeaderText += "\n  Line2";
        }
        groupRow.MinHeight = 40;
        colGroup.Rows.Add(groupRow);
     
        return colGroup;
    }

    Or you can set the AutoSizeRows property of the grid:
    radGridView1.AutoSizeRows = true;

    Let me know if I can assist you further.

    Regards,
    Dimitar
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Karl
    Karl avatar
    35 posts
    Member since:
    Dec 2013

    Posted 26 Jan in reply to Dimitar Link to this post

    Setting the MinHeight works but AutoSizeRows = true appears to have no effect.
  5. Karl
    Karl avatar
    35 posts
    Member since:
    Dec 2013

    Posted 26 Jan in reply to Karl Link to this post

    Forgot to mention this was with UI for WinForms Q1 2015. DLL version is 2015.1.331.20.
  6. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 27 Jan Link to this post

    Hello Karl,

    Thank you for writing back.

    Yes, I can confirm that the AutoSizeRows would not work with the old version. If you want to use this feature you should upgrade to latest version. If you cannot upgrade you can use the MinHeight property.

    Do not hesitate to contact us if you have other questions.
     
    Regards,
    Dimitar
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  7. Karl
    Karl avatar
    35 posts
    Member since:
    Dec 2013

    Posted 27 Jan in reply to Dimitar Link to this post

    The MinHeight solution you provided changes all rows.  Is there any way to change just the height row height of the grouped column?
  8. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 28 Jan Link to this post

    Hello Karl,

    Thank you for writing back.

    You can use the ViewRowFormatting event to set the height of all other rows:
    void radGridView1_ViewRowFormatting(object sender, RowFormattingEventArgs e)
    {
         e.RowElement.RowInfo.Height = 23;
    }

    I hope this will be useful.

    Regards,
    Dimitar
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready