Using the drawString method on a MouseEnter Event.

Posted on 2004-04-24
Last Modified: 2012-06-27

I would like to know how to use the drawString on a mouseEnter Event of, as an example, a button.  I know I have to use the Paint Event but I don't really know what parameters I have to use with the Paint Event (Object sender, PaintEventArgs e).

Question by:SVakten
LVL 23

Expert Comment

ID: 10910354
LVL 10

Accepted Solution

eternal_21 earned 150 total points
ID: 10910466
I'm not sure if I follow you, but if I do - this is what I did:


    bool mouseIsOver = false;
    private void button1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        e.Graphics.DrawString("Test", new System.Drawing.Font("Times New Roman", 10), System.Drawing.Brushes.Black, 5, 5);

    private void button1_MouseEnter(object sender, System.EventArgs e)
      this.mouseIsOver = true;

    private void button1_MouseLeave(object sender, System.EventArgs e)
      this.mouseIsOver = false;


Author Comment

ID: 10911566
Eternal_21, you followed me and I thank you, it works great!

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML - Color not displaying correctly in EMAIL. 6 49
How to read text with RegEx... 2 26
IEnumerable<T> to a List<T> 8 40
c# DateTime Format validation 4 47
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question