Highlight column of selected cell

3 posts, 1 answers
  1. Yuri
    Yuri avatar
    12 posts
    Member since:
    Jun 2011

    Posted 11 Dec 2018 Link to this post

    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. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3949 posts

    Posted 11 Dec 2018 Link to this post

    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.
  3. Yuri
    Yuri avatar
    12 posts
    Member since:
    Jun 2011

    Posted 12 Dec 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thank you very much.

    I wanted to be sure that is not made by single Property, I couldn't find.
Back to Top