DataGrid - Vertical Column Headings and Custom Cell Formatting

2 posts, 0 answers
  1. neil
    neil avatar
    9 posts
    Member since:
    Nov 2016

    Posted 30 Sep 2019 Link to this post

    Hi

    I have a data grid and I am wondering if the column header text can be vertical ?  If so, how do you make the text vertical?

    Within the grid I have columns with Y and N, I want to make the background of the cell Green if Y and Red if N - what do I need to do to achieve this?

     

    Neil

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3575 posts

    Posted 01 Oct 2019 Link to this post

    Hello, Neil,    

    In order make the header text vertical, feel free to use the following code snippet: 

            public RadForm1()
            {
                InitializeComponent();
                this.radGridView1.ViewCellFormatting+=radGridView1_ViewCellFormatting;
                this.radGridView1.TableElement.TableHeaderHeight = 90; 
            }
    
            private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
            {
                GridHeaderCellElement element = sender as GridHeaderCellElement;
                if (element != null)
                {
                    element.TextOrientation = Orientation.Vertical;
                    element.FlipText = true;
                } 
            }

    As to the question about styling the cell considering the data value, it is appropriate to use the CellFormatting event. Please refer to the following help article demonstrating how to use it: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/formatting-cells

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top