AutoSizeRows for data rows only

2 posts, 0 answers
  1. Phil
    Phil avatar
    15 posts
    Member since:
    Oct 2012

    Posted 19 Jan Link to this post

    I have a RadGridView using the VisualStudio2012Light theme which is exactly the style I want - I don't want anything to change when it comes to that at all, not the headers, summary rows, add new row, etc.

    I have some columns with WrapText enabled so they will stretch and auto size their parent rows where needed if AutoSizeRows is enabled.

    Now the problem comes in when AutoSizeRows is enabled. All non-data rows resize as well, breaking whatever heights were set as part of the theme. For maintainability I don't want to have to add explicit overrides/adjustments for heights in case the theme changes at a later stage. I am very happy with the theme and only want the rows to stretch in size and to never shrink below what the theme dictates.

    I'm using 2016 Q1 and am battling to find the correct event and property combinations to only allow my data rows to resize - I figured that preventing autosizing of non-data rows is probably the cleanest fix for now I don't know if there is any request perhaps to prevent AutoSizeRows from shrinking already themed heights?

    I've tried using the CreateRow event but can't figure out how to change enable/disable from there. The GridViewCreateRowEventArgs object has a RowElement property which hasn't been instantiated yet since the row doesn't exist. Must I instantiate that myself to set AutoSize to false? How would I create a default RowElement without changing anything else but that? If I can't use e.RowElement, how do I use e.RowInfo to set AutoSize to false?

    I've tried using the RowFormatting event but to no avail.

     Any assistance on this would be greatly appreciated.

     

     

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 20 Jan Link to this post

    Hi Phil,

    Thank you for writing.

    In order to use the default row height when the rows are auto-sized, you should set their minimum height. The following snippet shows how you can set the default and the minimum height for the system rows:
    radGridView1.MasterView.TableSearchRow.MinHeight = 30;
    radGridView1.MasterView.TableHeaderRow.MinHeight = 30;
    radGridView1.MasterView.TableFilteringRow.MinHeight = 30;
     
    radGridView1.TableElement.TableHeaderHeight = 30;
    radGridView1.TableElement.SearchRowHeight = 30;
    radGridView1.TableElement.FilterRowHeight = 30;

    I hope this will be useful. 

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top