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

Highlight column of selected cell

2 Answers 60 Views
VirtualGrid
This is a migrated thread and some comments may be shown as answers.
Yuri
Top achievements
Rank 1
Yuri asked on 11 Dec 2018, 09:38 AM

Hi,

VirtualGrid highlights a row with selected cell by default,

could you please assist me with information how can I highlight a column too?

Much thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 11 Dec 2018, 01:55 PM
Hello, Yuri,    

The easiest way to customize the virtual grid's cells, is to handle the CellFormatting event. Thus, considering which is the current row/column index you can achieve the desired selection. You can find below a sample code snippet:

public RadForm1()
{
    InitializeComponent();
    this.radVirtualGrid1.RowCount = 30;
    this.radVirtualGrid1.ColumnCount = 5;
    this.radVirtualGrid1.AutoSizeColumnsMode = Telerik.WinControls.UI.VirtualGridAutoSizeColumnsMode.Fill;
    this.radVirtualGrid1.CellValueNeeded += radVirtualGrid1_CellValueNeeded;
    this.radVirtualGrid1.CellFormatting += radVirtualGrid1_CellFormatting;
    this.radVirtualGrid1.SelectionMode = Telerik.WinControls.UI.VirtualGridSelectionMode.FullRowSelect;
}
 
private void radVirtualGrid1_CellFormatting(object sender, Telerik.WinControls.UI.VirtualGridCellElementEventArgs e)
{
    if (e.CellElement.RowElement.IsSelected ||
        (this.radVirtualGrid1.CurrentCell != null && e.CellElement.ColumnIndex == this.radVirtualGrid1.CurrentCell.ColumnIndex))
    {
        e.CellElement.DrawFill = true;
        e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
        e.CellElement.BackColor = Color.Orange;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
    }
}
 
private void radVirtualGrid1_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e)
{
    e.Value = "Data " + e.RowIndex + "." + e.ColumnIndex;
}



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.
0
Yuri
Top achievements
Rank 1
answered on 12 Dec 2018, 09:44 AM
Thank you very much.

I wanted to be sure that is not made by single Property, I couldn't find.
Tags
VirtualGrid
Asked by
Yuri
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Yuri
Top achievements
Rank 1
Share this question
or