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

Textfields height and width looks messed up in edit-mode

3 Answers 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nicklas
Top achievements
Rank 1
Nicklas asked on 26 Jun 2013, 02:49 PM
Hello 

When I enter edit mode in my grid the textboxes looks messed up, The height and width of the textboxes are not even near match. And the height of the first and last textbox is higher than the rest.

I want to get some space between the textboxes and also set the height and width of all the textboxes including my dropdown lists to the same.

Any idea what to do? I have tried setting the height and width to the same in itembound event and in a ItemCreated event with no luck.

Ive enclosed an image of how it looks, if it is to any help.


Appreciate any help! This is driving me nuts.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 27 Jun 2013, 06:02 AM
Hi Nicklas,

Please try the following code snippet.Hope this helps.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    foreach (GridEditFormItem edititem in RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem))
    {
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
        {
            if (col.ColumnType == "GridBoundColumn")
            {
                if (edititem.IsInEditMode)
                {
                    TextBox txtbx = (TextBox)edititem[col.UniqueName].Controls[0];
                    txtbx.Width = Unit.Pixel(100);
                    txtbx.Height = Unit.Pixel(40); 
                }
            }
            if (col.ColumnType == "GridDropDownColumn")
            {
                if (edititem.IsInEditMode)
                {
                    DropDownList droplist = (DropDownList)edititem[col.UniqueName].Controls[0];
                    droplist.Width = Unit.Pixel(108);
                    droplist.Height = Unit.Pixel(45);
                }
            }
        }
    }
}

Thanks,
Princy
0
Nicklas
Top achievements
Rank 1
answered on 27 Jun 2013, 07:49 AM
Thanks! Unfortunately for some weird reason, it does not change the size of the textboxes, I've stepped through the code and all the sizes are being set to the textboxes, it just wont accept the changes. I am starting to think that I have set something static of some kind that causes this.

I've realized now why a few of the textboxes are bigger than the rest, the first and last textbox is actually a numerictextbox, whilst the rest are just plain textboxes, but that shouldnt change the fact that it doesn't react on my changes.

Any idea?
0
Princy
Top achievements
Rank 1
answered on 28 Jun 2013, 07:39 AM
Hi,

I tried to replicate the issue,but no avail.Please provide your full code so that i may help.
Here is the code i tried using Numeric Textbox,Textbox,and Dropdownlist.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    foreach (GridEditFormItem edititem in RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem))
    {
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
        {
            if (col.ColumnType == "GridBoundColumn")
            {
                if (edititem.IsInEditMode)
                {
                    TextBox txtbx = (TextBox)edititem[col.UniqueName].Controls[0];
                    txtbx.Width = Unit.Pixel(100);
                    txtbx.Height = Unit.Pixel(40); 
                }
            }
            if (col.ColumnType == "GridDropDownColumn")
            {
                if (edititem.IsInEditMode)
                {
                    DropDownList drop = (DropDownList)edititem[col.UniqueName].Controls[0];
                    drop.Width = Unit.Pixel(108);
                    drop.Height = Unit.Pixel(45);
                }
            }
            if (col.ColumnType == "GridNumericColumn")
            {
                if (edititem.IsInEditMode)
                {
                    RadNumericTextBox drop = (RadNumericTextBox)edititem[col.UniqueName].Controls[0];
                    drop.Width = Unit.Pixel(107);
                    drop.Height = Unit.Pixel(45);
                }
            }
        }
    }
}

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