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

Changing column width not working

2 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 16 Dec 2010, 01:23 PM
If I set the width of a column in the master table view (using HeaderStyle.Width) and then set the width again to something different, the width doesn't change and seems to get stuck at the first width that had been set. (this is using TableLayout=Fixed and UseStaticHeaders=true, and AutoGenerateColumns=true)

Is there any way to clear the columns completely in the master table view so they are recreated when autogenerating new columns?

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Dec 2010, 06:25 AM
Hello Philip,

Give a try with the following code snippet to change the column width from code behind.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
   {
       RadGrid1.MasterTableView.AutoGeneratedColumns[4].HeaderStyle.Width = System.Web.UI.WebControls.Unit.Pixel(500);// changes single column width
       RadGrid1.MasterTableView.HeaderStyle.Width = System.Web.UI.WebControls.Unit.Pixel(500);//change all column width
   }

Thanks,
Princy.
0
Philip
Top achievements
Rank 1
answered on 06 Jan 2011, 05:54 PM
That worked, thanks
Tags
Grid
Asked by
Philip
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Philip
Top achievements
Rank 1
Share this question
or