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

Cursor Change on RadLabelElement within RadGridView GridViewCommandColumn

1 Answer 81 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 2
Mike asked on 17 Jul 2008, 06:06 PM

 

Hi Guys,

I am having a problem changing the Cursor icon to a hand while hovering or entering over a RadLabelElement within the RadGridView GridViewCommandColumn cell.  I am using the most current version of the controls.

The following is how my controls are placed:

I have a RadGridView control, with a GridViewCommandColumn that contains a RadMenuElement and 4 RadLabelElements.

My problem arises when I try to use the MouseEnter() event handler on the RadLabelElement to change the Cursor type from the default (arrow) to a Hand. It will not make the change.

The following is an outline of the source code that contains the problems described above:

  private void gvManageDocs_CellFormatting(object sender, CellFormattingEventArgs e)    
            {  
                    if (e.CellElement is GridCommandCellElement)  
                    {  
                            GridViewRowInfo gvrRow = e.CellElement.RowInfo;  
                            e.CellElement.Children.Clear();  
                            RadMenuElement buttonElement = new RadMenuElement();  
                            RadLabelElement lblLabel = new RadLabelElement();  
                                                                         
                            lblLabel.Text = "View";  
                            lblLabel.Click += new EventHandler(lblView_Click);  
                            lblLabel.MouseLeave += new EventHandler(lblLabel_MouseLeave);                                  
                            lblLabel.MouseEnter += new EventHandler(lblLabel_MouseEnter);  
                            lblLabel.ForeColor = Color.Blue;  
                            buttonElement.Items.Add(lblLabel);  
                            lblLabel = null;  
   
                            lblLabel = new RadLabelElement();  
                            lblLabel.Text = "Modify";  
                            lblLabel.Click += new EventHandler(lblModify_Click);  
                            lblLabel.MouseLeave += new EventHandler(lblLabel_MouseLeave);  
                            lblLabel.MouseEnter += new EventHandler(lblLabel_MouseEnter);  
                            lblLabel.ForeColor = Color.Blue;  
                            buttonElement.Items.Add(lblLabel);  
                            lblLabel = null;  
                            }          
                
                            e.CellElement.Children.Add(buttonElement);  
                    }  
 
 
void lblLabel_MouseEnter(object sender, EventArgs e)  
        {  
               Cursor = Cursors.Hand;  
               ((RadLabelElement)sender).ForeColor  = Color.Red;  
       }  
void lblLabel_MouseLeave(object sender, EventArgs e)  
        {  
            Cursor = Cursors.Arrow;  
            ((RadLabelElement)sender).ForeColor = Color.Blue;              
        }   
 

Please let me know what I can do to solve this issue.

Many thanks,
Mike

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Vasilev
Telerik team
answered on 18 Jul 2008, 12:29 PM
Hello Mike,

Thank you for writing.

Actually, you nearly made it. You only have to set the Cursor property for your instance of RadGridView instead of the Form. Please review the code-block below:
void lblLabel_MouseEnter(object sender, EventArgs e)   
{   
    this.radGridView1.Cursor = Cursors.Hand;   
    ((RadLabelElement)sender).ForeColor  = Color.Red;   
}   
void lblLabel_MouseLeave(object sender, EventArgs e)   
    this.radGridView1.Cursor = Cursors.Arrow;   
    ((RadLabelElement)sender).ForeColor = Color.Blue;               
}    

I hope this helps. If you have other questions, do not hesitate to contact me again.

Regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Mike
Top achievements
Rank 2
Answers by
Martin Vasilev
Telerik team
Share this question
or