How to set static row height

8 posts, 0 answers
  1. miro mrazik
    miro mrazik avatar
    8 posts
    Member since:
    Aug 2009

    Posted 21 Nov 2010 Link to this post

    Greetings,

    I put this RadGridView on my WPF form:

    <telerikStyle:RadGridView x:Name="gvOutbox" IsReadOnly="True" CanUserReorderColumns="True" CanUserResizeColumns="True" CanUserSortColumns="True"                   
    SelectionMode="Extended" telerikStyle:StyleManager.Theme="Office_Blue"/>

    This C# code simply loads data from database using Linq to EF:

    var db = new MyEntities();
      
    var records = from d in db.Records
                  select d;
      
    gvOutbox.ItemsSource = records;

    Everything's fine. Data is loaded into my grid, but one of my database field is of type TEXT and it holds multiline text. Now when I scroll horizontally through columns, GridView changes the height of the rows automatically when the multiline column is visible/invisible.
    How can I turn this behavior off? I'd like to see just first line of the multiline text and elipses button in that column and of course I want to have static height of my rows.

    Thank you
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 22 Nov 2010 Link to this post

    Hello miro mrazik,

    RadGridView has a property called RowHeight which will allow you to set a static height for all rows. Could you please try setting RowHeight to 25, for example.


    Regards,
    Milan
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  3. UI for WPF is Visual Studio 2017 Ready
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 22 Nov 2010 Link to this post

    Hello miro mrazik,

    Please find attached a sample project. It defines a CellTemplate and trims the long text.
    In addition, you can benefit the ToolTipTemplate property to show the full text on mouse over.

    Hope this helps.

    Kind regards,
    Veselin Vasilev
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  5. miro mrazik
    miro mrazik avatar
    8 posts
    Member since:
    Aug 2009

    Posted 22 Nov 2010 Link to this post

    Hi,

    I've already tried that property. Here is my xaml:

    <Window x:Class="RadGridViewRowHeight.MainWindow"
            Title="MainWindow" Height="350" Width="525" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
        <Grid>
            <telerik:RadGridView  Name="radGridView1" RowHeight="25" AutoGenerateColumns="True"/>
        </Grid>
    </Window>

    Here is my C# code:
    public partial class MainWindow : Window
     {
         class Customer
         {
             public int ID { get; set; }
             public string Name { get; set; }
             public string Address { get; set; }
         }
     
         public MainWindow()
         {
             InitializeComponent();
     
             var listOfCustomers = new List<Customer>();
             listOfCustomers.Add(new Customer { ID = 1, Name = "Miroslav Mrazik", Address = "Somewhere in Slovakia\nIn my hometown\nSlovakia" });
     
             radGridView1.ItemsSource = listOfCustomers;
         }
     }

    The result is a single line with height greater than 25 and it shows whole address in Address field (all three lines). 
  6. miro mrazik
    miro mrazik avatar
    8 posts
    Member since:
    Aug 2009

    Posted 22 Nov 2010 Link to this post

    Thank you Veselin for an example. That's what I'm trying to reach but my problem is that I have too much fields in my database table, so I would like to be able to set the row height and trim the text field value in run-time with AutoGenerateColumns set to True. Is there any way how to do that or I have to simply turn autogenerating columns off and hardcode all of my columns?

     
  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 25 Nov 2010 Link to this post

    Hello miro mrazik,

    Please find attached the modified project.

    Hope it helps.

    Sincerely yours,
    Veselin Vasilev
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  8. Sergey
    Sergey avatar
    9 posts
    Member since:
    Sep 2016

    Posted 13 Sep Link to this post

    RowHeight Property dont work if ExpressionDark theme used
  9. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    368 posts

    Posted 13 Sep Link to this post

    Hello Sergey,

    I'm attaching a sample project where the RowHeight property is respected in both parent and child RadGridView instances. Could you please have a look at it and let me know whether I've missed something of importance?

    May I also kindly ask you to continue this discussion in the other forum thread you've responded to? Thank you in advance for your cooperation and understanding.

    Regards,
    Dilyan Traykov
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for WPF is Visual Studio 2017 Ready