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

How to set the size of a GridMaskedBox Column

4 Answers 48 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ashok Sridhar
Top achievements
Rank 1
Ashok Sridhar asked on 05 Feb 2009, 04:31 AM
Hi,

     I need to limit the display size of a GridMaskedBox Column.  I actually need to limit the size of the textbox during editing.  The ItemStyle-Width is not working.  For that matter, I'm unable to set the display size for any of the Bound Columns.

Thanks

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Feb 2009, 07:36 AM
Hello Ashok,

You can try out the following code to set the width of the TextBox for a bound column and RadMaskedTextBox for a maskedcolumn to required width:
cs:
  protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
       if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            RadMaskedTextBox radmaskdtxtbx = (RadMaskedTextBox)editItem["MaskedColumnUniqueName"].Controls[0]; 
            radmaskdtxtbx.Width = Unit.Pixel(50); 
            TextBox txtbx = (TextBox)editItem["BoundColumnUniqueName"].Controls[0]; 
            txtbx.Width=Unit.Pixel(50); 
            
           
        } 

Thanks
Princy.
0
Ashok Sridhar
Top achievements
Rank 1
answered on 05 Feb 2009, 01:01 PM
Hello Princy,

             That works. Thanks,  But its very unfortunate that there is not declarative way to specify the size of the edit columns in the radgrid.

Thanks,
0
Sebastian
Telerik team
answered on 05 Feb 2009, 01:05 PM
Hi Ashok,

Actually there is a way by using declarative style editors. Review this topic from the documentation for more details:

http://www.telerik.com/help/aspnet-ajax/grdstylingthroughdeclarativecustomeditors.html

Kind regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ashok Sridhar
Top achievements
Rank 1
answered on 05 Feb 2009, 01:38 PM
Hello Sebastian,

This is great.  Thanks
Tags
Grid
Asked by
Ashok Sridhar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ashok Sridhar
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or