Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6212123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:27:32+00:00 2026-05-24T06:27:32+00:00

In event handler of Form Load, I have the following code Panel pHText =

  • 0

In event handler of Form Load, I have the following code

    Panel pHText = new Panel();
    Font myFont = new Font("Arial", 14);
    pHText.Location=new Point(10,10);
    pHText.Size=new Size(200,200);
    pHText.BackColor = Color.White;
    Graphics g = pHText.CreateGraphics();
    g.DrawLine(new Pen(Color.Black), 0, 0, 10, 10);
    g.DrawString("text", myFont, Brushes.Blue, 10, 10);
    Controls.Add(pHText);

The white Panel is shown in the form, but those drawing of line and string are not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:27:33+00:00Added an answer on May 24, 2026 at 6:27 am

    this code will go in your form load event

    Panel pHText = new Panel();
    pHText.Name = "ctrId"; //specify control name, to access it in other parts of your code
    pHText.Location = new Point(10, 10);
    pHText.Size = new Size(200, 200);
    pHText.BackColor = Color.White;
    pHText.Paint += paintingUrCtr;//adding onpaint event
    Controls.Add(pHText)
    

    add paint event named paintingUrCtr.

    private void paintingUrCtr(object sender, PaintEventArgs e)
    {
            Font myFont = new Font("Arial", 14);
            e.Graphics.DrawLine(new Pen(Color.Black),  0, 0, 10, 10);
            e.Graphics.DrawString("text", myFont, Brushes.Blue, 10, 10);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code in the form_Load function System.Windows.Forms.Timer newtimer = new Timer(); newtimer.Tick
I have a form with a panel on which I dynamically load multiple user
To create a new event handler on a control you can do this c.Click
I have some event handler on a boundary class that manages a persistence mechanism
I have a simple event handler with a ItemAdding event that changes a column
I have a sharepoint event handler which I want to activate for a single
i load a form into a jquery ui dialog. i have a submit button
I have an ADOStoredProc on my form. It's not visual but in code.Normally it's
I want to attach a 'click' event handler to the first child of an
I've implemented my own event handler and added it to the selection model of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.