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

Column width size

2 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Agyeman
Top achievements
Rank 1
Agyeman asked on 05 Aug 2008, 04:14 PM
How do i programmatically specify grid colum width size as I add columns to my grid view.
thanks.

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 Aug 2008, 05:25 AM
Hello Agyeman,

Please try the following code:
gridBoundColumn.HeaderStyle.Width = Unit.Pixel(100); 

Kind regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Princy
Top achievements
Rank 2
answered on 06 Aug 2008, 07:07 AM
Hello Agyeman,

If you are trying to add the columns in the code behind to a statically formed grid(aspx),  then you need to add the column to the Grid's ColumnCollection first and then set the required properties as shown below.
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" > 
</telerik:RadGrid> 

cs:
       GridBoundColumn bndcol = new GridBoundColumn(); 
        RadGrid1.MasterTableView.Columns.Add(bndcol); 
        // set properties 
        bndcol.UniqueName = "Column"
        bndcol.HeaderText = "Column"
        bndcol.HeaderStyle.Width = Unit.Pixel(150); 

Thanks
Princy.


Tags
Grid
Asked by
Agyeman
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Princy
Top achievements
Rank 2
Share this question
or