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

column width for autogenerated column

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alyssa
Top achievements
Rank 1
Alyssa asked on 23 Dec 2013, 01:33 PM
Hi,
How to set column width for autogenerated column?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Dec 2013, 01:51 PM
Hi Alyssa

Please try any of the following code snippet to set the column width for the autogenerated columns.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    GridColumn gridCol = RadGrid1.MasterTableView.GetColumn("Name");
    gridCol.HeaderStyle.Width = Unit.Pixel(100);
 
                      OR
 
    foreach (GridColumn column in RadGrid1.MasterTableView.AutoGeneratedColumns)
    {
        if (column.DataType == typeof(string))
        {
            column.HeaderStyle.Width = Unit.Pixel(100);          
        }
    }
}

Thanks,
Princy
Tags
Grid
Asked by
Alyssa
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or