gridview edit mode textbox too small

7 posts, 0 answers
  1. Nino
    Nino avatar
    9 posts
    Member since:
    Apr 2013

    Posted 10 May 2013 Link to this post

    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
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 14 May 2013 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 15 May 2013 Link to this post

    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?
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 15 May 2013 Link to this post

    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
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 20 May 2013 Link to this post

    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?
  7. Yungsung
    Yungsung avatar
    2 posts
    Member since:
    Oct 2010

    Posted 21 Jun in reply to Emanuel Varga Link to this post

    why is so difficult?

     

  8. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 22 Jun Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready