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

Header cell image gets reset on mouse over

2 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter Luth
Top achievements
Rank 1
Peter Luth asked on 16 Feb 2009, 10:14 AM
Hello,

I am using the RowFormatting event to set an image to the GridRowHeaderCellElement. This is working. However when a user hovers the mouse over the header cell, the image gets removed, and it will only get reset if he clicks a row again.

Here is the code I use for RowFormatting:

void RowFormatting_ImageChanging(object sender, Telerik.WinControls.UI.RowFormattingEventArgs e) 
        { 
            GridRowHeaderCellElement grhce = e.RowElement.Children[0] as GridRowHeaderCellElement; 
 
            if (grhce != null
            { 
                GridViewEditableEntry aa = e.RowElement.RowInfo.DataBoundItem as GridViewEditableEntry; 
                if (aa != null
                { 
                    if (aa.Changed) 
                        grhce.Image = myimage1; 
                    else if (aa.IsEditable) 
                        grhce.Image = myimage2; 
                    else if (!aa.IsEditable) 
                        grhce.Image = myimage3; 
                } 
                else 
                { 
                    grhce.Image = null
                } 
            } 
        } 

How can I prevent the header cell image to get reset?

2 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 16 Feb 2009, 05:31 PM
Hi Martin,

You can do this by using custom row header cells. You should process the CreateCell event. Please consider the code snippet below:

void radGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e) 
    if (e.CellType == typeof(GridRowHeaderCellElement)) 
    { 
        e.CellElement = new MyHeaderCell(e.Column, e.Row); 
    } 
 
public class MyHeaderCell : GridRowHeaderCellElement 
    public MyHeaderCell(GridViewColumn column, GridRowElement row) 
        : base(column, row) 
    { 
    } 
 
    public override void UpdateInfo() 
    { 
        base.UpdateInfo(); 
        this.Image = Resources.blue; 
    } 
 

I hope this helps. Do not hesitate to write us back if you have questions.

Regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Peter Luth
Top achievements
Rank 1
answered on 17 Feb 2009, 10:38 AM
Thanks. Works like a charm!
Tags
GridView
Asked by
Peter Luth
Top achievements
Rank 1
Answers by
Jack
Telerik team
Peter Luth
Top achievements
Rank 1
Share this question
or