Solved

Applying the same width to all textboxes in edit mode (telerik radgrid)

Posted on 2013-06-25
5
550 Views
Last Modified: 2013-09-02
Hello!

When I enter edit mode in a Telerik radgrid I end up with all the textboxes beeing in different width.

I thought of solving this, by looping through all the items that is beeing edited and set them to System.Web.UI.WebControls.Unit.Pixel(300); to change the size.

I have tried with a loop looking something like below, but obviously this will yield error,

Any idea what to do to make them into the same size?

foreach (GridEditFormItem EdItem in rgRelMaterial.Columns)
  {
        EdItem.Width = System.Web.UI.WebControls.Unit.Pixel(300);
  }
0
Comment
Question by:clooak
  • 3
  • 2
5 Comments
 
LVL 39

Expert Comment

by:Kyle Abrahams
ID: 39274771
foreach (Telerik.Web.UI.GridColumn c in rgRelMaterial.MasterTableView.RenderColumns)
            {
                c.HeaderStyle.Width = Unit.Pixel(300);
            }
0
 

Author Comment

by:clooak
ID: 39274831
I thought of that as first aswell, but the problem is that Telerik differs the textbox in the grid and the edit items.

When I use the code you gave, it will only change the textboxes in normal view (before and after edit) not the textboxes in edit mode.

So I need to determine somehow if the textbox found is in editmode or not, so that I don't alter the normal textboxes.

Tricky  I know :(
0
 

Accepted Solution

by:
clooak earned 0 total points
ID: 39274860
I think I sorted it out, by using onColumnCreated event (since the edit textboxes are created on the fly)

Something like this should work

protected void rgRelMaterialLoad_ColumnCreated(object sender, Telerik.Web.UI.GridColumnCreatedEventArgs e)
        {

 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {   
         // Insert code here to edit the width of the Column added.
    }
}

Open in new window

0
 
LVL 39

Expert Comment

by:Kyle Abrahams
ID: 39275718
Test it and if it is feel free to accept your own answer as the solution :-).  Good knowledge for anyone else coming through.
0
 

Author Closing Comment

by:clooak
ID: 39457789
Solved it myself
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now