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

  • SEARCH
  • Home
  • 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 6837159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:26:35+00:00 2026-05-26T23:26:35+00:00

I am trying to draw with brush on UserControl control. I can draw lines,

  • 0

I am trying to draw with brush on UserControl control. I can draw lines, circles and rectangles. I don’t exactly understand why I cannot draw with brush. The code below gives me just point on MouseDown and then it moves to the position set in MouseUp. There is no content drawn during MouseMove. I suppose that I do not understand some basic rule here.

This code works for lines:

public override void Draw(Graphics graphics) {
  graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  graphics.DrawLine(new Pen(this.Color, this.PenSize), startPoint, endPoint);
}

This code I am trygin to adapt for brush:

public override void Draw(Graphics graphics) {
  if (this.bitmap != null) {
    graphics = Graphics.FromImage(this.bitmap);
    graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    graphics.DrawEllipse(new Pen(this.Color, this.PenSize), startPoint.X, startPoint.Y,
                         this.PenSize, this.PenSize);
    graphics.DrawImage(this.bitmap, 0, 0);
  }
}

This code repaints list of objects:

private void UserControl_Paint(object sender, PaintEventArgs e) {
  if (ObjectsList != null) {
    ObjectsList.Draw(e.Graphics);
  }
}

As the code presents I am trying to grab bitmap image before and after point-like line drawing. Should I do it other way?

  • 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-26T23:26:36+00:00Added an answer on May 26, 2026 at 11:26 pm

    I don’t really understand your question, but in your second code their seems to be a mistake. Maybe you should try this one:

    public override void Draw(Graphics graphics)
    {
        if (this.bitmap != null)
        {
            Graphics g = Graphics.FromImage(this.bitmap);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.DrawEllipse(new Pen(this.Color, this.PenSize), startPoint.X, startPoint.Y, this.PenSize, this.PenSize);
            graphics.DrawImage(this.bitmap, 0, 0);
        }
    }
    

    Otherwise, you are drawing the bitmap on the bitmap itself. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to draw a line. I wrote a code like below. UIColor *currentColor
I'm trying to draw some simples lines with the iPhone/Touch SDK. I'd like to
I am trying to draw a series of rectangles using OpenGL but some of
so I am trying to draw some grid lines that in landscape go all
I'm trying to draw a vertical scrollbar for my G15 applet, but am having
I'm trying to draw over the whole screen by using the desktop canvas and
I am trying to draw a textured cube using just 8 vertices and one
I am trying to draw a circle using Windows Form at runtime inside a
I'm trying to draw vertical text in win32 GDI api. I call CreateFont() with
I'am trying to draw a line above mapkit. If I try to set the

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.