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

DataGrid - Vertical Column Headings and Custom Cell Formatting

1 Answer 1051 Views
GridView
This is a migrated thread and some comments may be shown as answers.
neil
Top achievements
Rank 1
neil asked on 30 Sep 2019, 05:26 PM

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

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 Oct 2019, 12:16 PM

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.
Tags
GridView
Asked by
neil
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or