How can i change the color or do smthing else when mouse pointer go over a button....

help with all mouse event handler

(i have tried some codes but errors)

[eg: Error 1 No overload for 'Form_Over' matches delegate 'System.EventHandler' ]

pls help...
thnx in advnc...


Recommended Answers

All 3 Replies

Could you send in the code you already have?

Deginer code(delegate)

            // simpleButton1
            this.simpleButton1.Location = new System.Drawing.Point(60, 55);
            this.simpleButton1.Name = "simpleButton1";
            this.simpleButton1.Size = new System.Drawing.Size(100, 23);
            this.simpleButton1.TabIndex = 6;
            this.simpleButton1.Text = "Fagmann01";
            this.simpleButton1.Visible = false;
            this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click);
            this.MouseHover += new System.Windows.Forms.MouseEventHandler(this.simpleButton1_MouseHOver);


private void simpleButton1_MouseHOver(object sender, System.Windows.Forms.MouseEventArgs e)
            simpleButton1.BackColor = System.Drawing.Color.Black;



You are adding a MosueHover event to the form. Try:

this.simpleButton1.MouseHover += new System.EventHandler(this.simpleButton1_MouseHover);

if you want to change the back colour when the mouse is over the button you would be better to look at MouseEnter and MouseLeave so that you can change the colour back when the mouse moves away.

Remember to mark this thread as solved if this has answered your question

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.