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

change style on onmouseover for radlistbox

4 Answers 290 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
vighnesh
Top achievements
Rank 1
vighnesh asked on 17 Feb 2009, 06:42 AM
Hello,

How do we change background color of a radlistitem in radlistbox when mouse is over that specific item programatically?
Currently we can see background color getting changed only when item is selected. Thank you.

4 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 17 Feb 2009, 12:13 PM
Hi vighnesh,

Thank you for the question.

In order to change the colors of a RadListBoxItem on mouse hover, please subscribe to its MouseEnter and MouseLeave events:
public partial class Form1 : Form  
    {  
        public Form1()  
        {  
            InitializeComponent();  
 
            for (int i = 0; i < this.radListBox1.Items.Count; i++)  
            {  
                ((RadListBoxItem)this.radListBox1.Items[i]).MouseLeave += new EventHandler(Form1_MouseLeave);  
                ((RadListBoxItem)this.radListBox1.Items[i]).MouseEnter += new EventHandler(Form1_MouseEnter);  
            }  
        }  
 
        void Form1_MouseEnter(object sender, EventArgs e)  
        {  
            RadListBoxItem item = sender as RadListBoxItem;  
            (((FillPrimitive)item.Children[0])).BackColor = Color.Orange;  
            (((FillPrimitive)item.Children[0])).BackColor2 = Color.Red;  
            (((FillPrimitive)item.Children[0])).BackColor3 = Color.Red;  
            (((FillPrimitive)item.Children[0])).BackColor4 = Color.Red;  
        }  
 
        void Form1_MouseLeave(object sender, EventArgs e)  
        {  
            RadListBoxItem item = sender as RadListBoxItem;  
            (((FillPrimitive)item.Children[0])).BackColor = Color.White;  
            (((FillPrimitive)item.Children[0])).BackColor2 = Color.White;  
            (((FillPrimitive)item.Children[0])).BackColor3 = Color.White;  
            (((FillPrimitive)item.Children[0])).BackColor4 = Color.White;  
        }  
    } 

I hope this helps. If you have additional questions, feel free to contact me.

Kind regards,
Nikolay
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
vighnesh
Top achievements
Rank 1
answered on 18 Feb 2009, 01:29 PM
Thank you. that worked for me.
0
Amir
Top achievements
Rank 1
answered on 19 Jun 2015, 03:38 PM

I do have the latest version of DevCraft but I cannot find the right lib for the FillPrimitive.

I am not seeing any WinControls.Primitives to add to VS resources!

0
Hristo
Telerik team
answered on 23 Jun 2015, 01:26 PM
Hello Amir,

Thank you for writing.

The FillPrimitive class is located in the Telerik.WinControls.dll assembly, so in order to access them you would need to reference it.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
vighnesh
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
vighnesh
Top achievements
Rank 1
Amir
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or