Reputation: 230
i need to put a title header in Telerik Gridview in winforms. i tried
radGridView1.MasterGridViewTemplate.Columns["myColumn"].HeaderText = "first line \n Second line \n third line";
but it doesn't work. my referred link : http://www.telerik.com/community/forums/winforms/gridview/2-lines-of-text-in-the-column-header.aspx
Upvotes: 2
Views: 2881
Reputation: 3120
When you set the text as you mentioned, the text will be multiline, but the header cell height is not enough, hence you are not able to see that other lines. You can change the header cells height by using this property:
radGridView1.TableElement.TableHeaderHeight = 100;
radGridView1.MasterGridViewTemplate.Columns[0].HeaderText = "first line \n Second line \n third line";
Alternative way to do that is to use the AutoSizeRows property (set to true), but this will auto size all rows in the grid according to their content, not just the header row.
Upvotes: 1
Reputation: 4209
I tested the following and it is working:
In the designer set AutoSizeMode = ColumnHeader
Then add this line of code:
this.radGridView1.Columns[0].HeaderText = "This is a \n multiline \n header text";
Please note that the index [0] is relevant my test code. You shall set your column index considering that the first column is 0.
This is the result I got:
Let us know if this works for you.
Upvotes: 2