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

How to set width of RadComboBox in GridDropDownColumn?

3 Answers 516 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Arno
Top achievements
Rank 2
Arno asked on 02 Jan 2011, 06:19 PM
Hi,

The code below does not result in the RadComboBox being resized to a width of 35 em. How should I do that?

<telerik:GridDropDownColumn UniqueName="ProductVariant" ListTextField="name" ListValueField="id"             DataSourceID="LinqDataSourceProductVariant" HeaderText="Product variant*" DataField="product_variant"  DropDownControlType="RadComboBox" AllowSorting="true" AllowFiltering="false" ItemStyle-Width="35em">
</telerik:GridDropDownColumn>

By the way, it works when I set the DropDownControlType to be a regular DropDownList, but then the dropdownlist is not styled like to other items:

<telerik:GridDropDownColumn UniqueName="ProductVariant" ListTextField="name" ListValueField="id"
DataSourceID="LinqDataSourceProductVariant" HeaderText="Product variant*" DataField="product_variant"
DropDownControlType="DropDownList" AllowSorting="true" AllowFiltering="false"
ItemStyle-Width="35em">
</telerik:GridDropDownColumn>

3 Answers, 1 is accepted

Sort by
1
Accepted
Shinu
Top achievements
Rank 2
answered on 03 Jan 2011, 05:49 AM
Hello,

You can try setting the  width of RadComboBox from code behind. Here is the sample code.

C#:
protected void grdEmail_ItemCreated(object sender, GridItemEventArgs e)
    {
   if (e.Item is  GridEditFormItem && e.Item.IsInEditMode)
        {
    RadComboBox combo = (RadComboBox)editform["UniqueName"].Controls[0];
   combo.Width = Unit.Pixel(20);
        }
     }

Thanks,
Shinu.
0
Arno
Top achievements
Rank 2
answered on 03 Jan 2011, 07:45 AM
Thanks a lot Shinu! I tried something like that but did not realize how to get to the control. This works perfectly!
0
Johnny
Top achievements
Rank 3
Bronze
Iron
Iron
answered on 22 Aug 2022, 08:33 AM | edited on 22 Aug 2022, 08:58 AM

Hello there, Is there a way to do this in VB? I have tried, however, I cannot seem to get it to work. Thanks!

EDIT:

I got it. To whoever might be interested, you can find a sample code below:

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
           
            Dim ddl As RadComboBox = DirectCast(item("YourItemNameHere").Controls(0), RadComboBox)
            ddl.Width = 130
           
        End If
    End Sub

Tags
Grid
Asked by
Arno
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Arno
Top achievements
Rank 2
Johnny
Top achievements
Rank 3
Bronze
Iron
Iron
Share this question
or