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

gridview edit mode textbox too small

9 Answers 133 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nino
Top achievements
Rank 1
Nino asked on 10 May 2013, 01:41 PM
Hi all, 

i modified the default font of a radgridview to a bigger one (design, property Font.Size) and now when i enter in edit mode on textboxcell 
the text itself keep the same font size, but the textbox is smaller and cut bottom of text out (see attached pictures).

Does anybody knows how to fix it please?
Am i using the correct way to change the font?

Thanks 

Nino

9 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 14 May 2013, 08:29 PM
Hello Nino,

I believe you should report this issue, because this should be fixed.

As a workaround you can use either of these 2 approaches:
// you could calculate the size manually when changing the font for the grid
var fontSize = 20;
gridView.Font = new Font(gridView.Font.FontFamily, fontSize);
using (var graphics = gridView.CreateGraphics())
{
    var size = graphics.MeasureString("T", gridView.Font);
    gridView.TableElement.RowHeight = Convert.ToInt32(Math.Ceiling(size.Height)) + 5;
}
 
// or use the grid autosize rows
gridView.AutoSizeRows = true;

Best Regards,
Emanuel Varga, MVP
0
Stefan
Telerik team
answered on 15 May 2013, 10:46 AM
Hello guys,

Thank you both for writing.

@Emanuel - welcome back :)

By default, the Rows in RadGridView have some specified height according to the theme used. Changing the font of the control will change the size of the text in the cells and if you want to let the grid size its rows to accommodate its cells content, you have to use the AutoSizeRows property.

So I do now think there is something we should log from this case. Please correct me if I am wrong?

The grid 
Greetings,
Stefan
the Telerik team
RadChart for WinForms is obsolete. Now what?
0
Emanuel Varga
Top achievements
Rank 1
answered on 15 May 2013, 10:53 AM
Hello Sefan,

There is an issue because even though the actual rows change their height according to font, theme and so on, they grow just enough to accommodate the text drawn on the cell - not taking into account the fact that editors need a bit more space for borders, padding and so on. So either the row height should be a bit taller from to accommodate the editor, or, the row height should change in edit mode.

This works for AutoSizeRows, but if autosize is not required (with the default font, the rows are too small for some), and just the font is changed, you can see this behavior.

If you try a simple example of setting the font to 30 you will see this issue (at least with the textbox editor - i haven't tested the rest)

@Stefan - thank you and nice to see you too :)

Best Regards,
Emanuel Varga, MVP
0
Stefan
Telerik team
answered on 20 May 2013, 07:59 AM
Hello,

Thank you for the clarification Emanuel. 

For the time being we will not add this as a feature for two reasons:
1. This would be a breaking change for the existing users using RadGridView.
2. This might slow down the grid in some cases.

There is an easy way to size the rows (with AutoSizeRows) and for the time this approach should be used.

Thank you for the proposal guys.
 
All the best,
Stefan
the Telerik team
RadChart for WinForms is obsolete. Now what?
0
Yungsung
Top achievements
Rank 1
answered on 21 Jun 2016, 09:09 PM

why is so difficult?

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Jun 2016, 10:25 AM
Hello Yungsung,

Thank you for writing. 

I suppose that you are experiencing the same difficulty with the small editor when multiline text is available. Note that you can enlarge the editor by setting the RadTextBoxEditor.Multiline property to true:
private void Form1_Load(object sender, EventArgs e)
{
    this.customersTableAdapter.Fill(this.nwindDataSet.Customers);
    this.radGridView1.DataSource = this.customersBindingSource;
    foreach (GridViewColumn col in this.radGridView1.Columns)
    {
        col.WrapText = true;
    }
 
    this.radGridView1.AutoSizeRows = true;
 
    this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
}
 
private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    RadTextBoxEditor tb = e.ActiveEditor as RadTextBoxEditor;
    if (tb != null)
    {
        tb.Multiline = true;
    }
}

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
J
Top achievements
Rank 1
answered on 23 Mar 2018, 02:53 PM

Hello 

I know this post is old but I have the same problem as Nino. Is there any other way to fix it not setting multiline and have editor filled  the entire cell? Row height and font size is fixed so no autosize.

Ver 2018.1.220.40

JB

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Mar 2018, 11:29 AM
Hello, JB, 
  
If you set the RadGridView.Font property it will affect the font to all cells. It is normal that the row's height won't be adjusted if the AutoSizeRows property remains false. As to the height of the input editor, instead of enabling its multiline functionality, you can specify the RadTextBoxEditorElement.TextBoxItem.MinSize property to the desired height in the CellEditorInitialized event: 
private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    RadTextBoxEditor tb = e.ActiveEditor as RadTextBoxEditor;
    if (tb != null)
    {
        RadTextBoxEditorElement el = tb.EditorElement as RadTextBoxEditorElement;
        if (el != null)
        {
             
            el.TextBoxItem.MinSize = new Size(0, 50); 
        }
    }
}

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
J
Top achievements
Rank 1
answered on 28 Mar 2018, 05:45 AM
Perfect. Thank you
Tags
GridView
Asked by
Nino
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Stefan
Telerik team
Yungsung
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
J
Top achievements
Rank 1
Share this question
or