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

ColumnGroupsView height

5 Answers 91 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dominik
Top achievements
Rank 1
Dominik asked on 23 Jul 2018, 11:28 AM

Sample code below. Just copy, paste and run. :)

var grid = new RadGridView
{
    Dock = DockStyle.Fill,
    AutoSizeRows = false,
    AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
     
};
 
grid.Columns.Add(new GridViewTextBoxColumn() { Name = "column1", HeaderText = "Column 1" });
grid.Columns.Add(new GridViewTextBoxColumn() { Name = "column2", HeaderText = "Column 2" });
grid.Columns.Add(new GridViewTextBoxColumn() { Name = "column3", HeaderText = "Column 3" });
grid.Columns.Add(new GridViewTextBoxColumn() { Name = "column4", HeaderText = "Column 4" });
 
var columnGroupsView = new ColumnGroupsViewDefinition();
columnGroupsView.ColumnGroups.Add(new GridViewColumnGroup("Group 1 Line 1" + Environment.NewLine + "Group 1 Line 2"));
columnGroupsView.ColumnGroups[columnGroupsView.ColumnGroups.Count - 1].Rows.Add(new GridViewColumnGroupRow());
columnGroupsView.ColumnGroups[columnGroupsView.ColumnGroups.Count - 1].Rows[0].ColumnNames.Add("column1");
columnGroupsView.ColumnGroups[columnGroupsView.ColumnGroups.Count - 1].Rows[0].ColumnNames.Add("column2");
 
columnGroupsView.ColumnGroups.Add(new GridViewColumnGroup("Group 2 Line 1" + Environment.NewLine + "Group 2 Line 2"));
columnGroupsView.ColumnGroups[columnGroupsView.ColumnGroups.Count - 1].Rows.Add(new GridViewColumnGroupRow());
columnGroupsView.ColumnGroups[columnGroupsView.ColumnGroups.Count - 1].Rows[0].ColumnNames.Add("column3");
columnGroupsView.ColumnGroups[columnGroupsView.ColumnGroups.Count - 1].Rows[0].ColumnNames.Add("column4");
 
grid.ViewDefinition = columnGroupsView;
 
var form = new RadForm();
form.Controls.Add(grid);
form.ShowDialog();

 

How to change by code height of group row? Please see attached image.

Important: I want to stay with AutoSizeRows = false.

5 Answers, 1 is accepted

Sort by
0
Dominik
Top achievements
Rank 1
answered on 23 Jul 2018, 11:40 AM
Also how to change second row height (columns).
0
Dimitar
Telerik team
answered on 24 Jul 2018, 09:38 AM
Hi Dominik,

You need to set the RowSpan and MinHeight properties. Here is an example:
var group = new GridViewColumnGroup("Group 1 Line 1" + Environment.NewLine + "Group 1 Line 2");
group.RowSpan = 50;
columnGroupsView.ColumnGroups.Add(group);
 
var groupRow = new GridViewColumnGroupRow();
groupRow.MinHeight = 50;
 
columnGroupsView.ColumnGroups[columnGroupsView.ColumnGroups.Count - 1].Rows.Add(groupRow);

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
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.
0
Dominik
Top achievements
Rank 1
answered on 25 Jul 2018, 09:42 AM
Setting MinHeight do GridViewColumnGroupRow is working but... this also changed the height od filtering row and data rows (which is not intentional).
0
Accepted
Dimitar
Telerik team
answered on 27 Jul 2018, 07:15 AM
Hi Dominik,

You need to manually set the height of the rows. Here is  the code:
foreach (var item in grid.Rows)
{
   item.Height = 25;
}

Currently, this cannot be done for the new row and it should have the height of the group row.

I hope this will be useful. 

Regards,
Dimitar
Progress Telerik
Get quickly and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Dominik
Top achievements
Rank 1
answered on 30 Jul 2018, 08:52 AM

Not the perfect solution but I will use it. :) Thanks!

Tags
GridView
Asked by
Dominik
Top achievements
Rank 1
Answers by
Dominik
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or