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

Hot Tracking On rows AND Columns

2 Answers 195 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tobias
Top achievements
Rank 1
Tobias asked on 19 Aug 2014, 08:54 AM
Hi @all, as mentioned above i am searching for solution to display hot tracking in both ... rows and colums. Is that possible ?

Thanks alot

Greetings

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 21 Aug 2014, 02:43 PM
Hello Tobias,

Thank you for writing.

By default, RadGridView offers row hot tracking functionality which is controlled by the TableElement.EnableHotTracking property. You can easily add a functionality for column hot tracking using the RadGridView.MouseMove and the RadGridView.ViewCellFormatting events. Here is a sample code snippet, demonstrating how to achieve it:
public Form1()
{
    InitializeComponent();
 
    this.radGridView1.TableElement.EnableHotTracking = true;
}
 
string columnName = string.Empty;
GridViewColumn currentColumn = null;
 
private void radGridView1_MouseMove(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.None)
    {
        GridCellElement cell = this.radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridCellElement;
       
        if (cell != null)
        {
            if (currentColumn != cell.ColumnInfo)
            {
                columnName = cell.ColumnInfo.Name;
                if (currentColumn != null)
                {
                    currentColumn.Tag = null;
                }
                currentColumn = cell.ColumnInfo;
                cell.ColumnInfo.Tag = "HotTracking";
            }
        }
    }
}
 
private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.Row is GridViewDataRowInfo)
    {
        if (e.Column.Tag == "HotTracking")
        {
            e.CellElement.BackColor = Color.FromArgb(255, 251, 216);
            e.CellElement.DrawFill = true;
            e.CellElement.GradientStyle = GradientStyles.Solid;
        }
        else
        {
            e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
            e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
        }
    }
}
 
private void radGridView1_MouseLeave(object sender, EventArgs e)
{
    if (currentColumn != null)
    {
        currentColumn.Tag = null;
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
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
Tobias
Top achievements
Rank 1
answered on 22 Aug 2014, 07:20 AM
Worked perfect ! Thank you very much.
Tags
GridView
Asked by
Tobias
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Tobias
Top achievements
Rank 1
Share this question
or