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

Highlight grid column

3 Answers 42 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aleksandr
Top achievements
Rank 1
Aleksandr asked on 19 May 2014, 08:10 AM
Hello.
I'm using RadGridView control where I use columns as dates in month like:
| 1 | 2 | 3 |...... | 31 |
I need a way to highlight 'today' column.
Thank you in advance.

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 19 May 2014, 08:34 AM
Hi Aleksandr,

Thank you for writing.

To do that you should set the grid SelectionMode to CellSelect, and the just select the desired cells:
radGridView1.SelectionMode = GridViewSelectionMode.CellSelect;
foreach (GridViewRowInfo row in radGridView1.Rows)
{
    row.Cells["MyColumn"].IsSelected = true;
}

I hope this helps.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Aleksandr
Top achievements
Rank 1
answered on 19 May 2014, 09:28 AM
Thank you. But when I click on some cell then highlighted cells lose their selection.
I need 'today' column to be highlighted all the time, maybe by changing its cells border. Can you help me, please?
0
Stefan
Telerik team
answered on 19 May 2014, 10:52 AM
Hello and thank you for the clarification.

In this case you should use the formatting events of RadGridView. Here is a small sample

void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
        {
            if (e.Column.Name == "DecimalColumn")
            {
                e.CellElement.DrawFill = true;
                e.CellElement.BackColor = Color.Red;
            }
            else
            {
                e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
            }
        }

Similarly, you can introduce any modification you want. Here you can find more information about the formatting events: http://www.telerik.com/help/winforms/gridview-cells-formatting-cells.html.

I hope that you find this information useful.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Aleksandr
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Aleksandr
Top achievements
Rank 1
Share this question
or