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 7489121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:12:11+00:00 2026-05-29T15:12:11+00:00

I have a VB.NET WinForms application. I am drawing a bunch of shapes on

  • 0

I have a VB.NET WinForms application.
I am drawing a bunch of shapes on a panel programmatically with GDI+.
Now I want to hightlight a small rectangular portion of that panel in some way. The highlighted area will move around a lot. I don’t want to redraw the whole panel, because there is too much processing involved and it causes flicker.
What it the best way to do this?

Thanks.

  • 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-29T15:12:12+00:00Added an answer on May 29, 2026 at 3:12 pm

    Can you add a transparent panel as a child of your existing panel (and dock it), and then do your highlights on the transparent panel?

    Here’s a very rudimentary example:

    public partial class Form1 : Form
    {
        private Panel pan = new Panel();
        private Panel trans = new Panel();
    
        private bool clicked { get; set; }
        private Point mouse { get; set; }
    
        public Form1()
        {
            InitializeComponent();
            this.Load += new EventHandler(Form1_Load);
        }
    
        public void Form1_Load(object sender, EventArgs e)
        {
            pan.Dock = DockStyle.Fill;
            pan.BackColor = Color.White;
    
            trans.Dock = DockStyle.Fill;
            trans.BackColor = Color.FromArgb(0, 0, 0, 0);
    
            pan.Paint += new PaintEventHandler(DrawSomeShapes);
            trans.MouseClick += new MouseEventHandler(trans_MouseClick);
            trans.Paint += new PaintEventHandler(DrawHighlight);
    
            pan.Controls.Add(trans);
            this.Controls.Add(pan);
    
            trans.BringToFront();
        }
    
        public void DrawSomeShapes(object sender, PaintEventArgs e)
        {
            var g = e.Graphics;
    
            var p = new Pen(Color.Black, 1F);
            g.DrawRectangle(p, new Rectangle(0, 0, 100, 100));
            g.DrawRectangle(p, new Rectangle(20, 20, 50, 50));
            g.DrawRectangle(p, new Rectangle(10, 50, 100, 25));
            g.DrawRectangle(new Pen(Color.Red, 1F), new Rectangle(new Point(50, 50), new Size(50, 50)));
        }
    
        public void DrawHighlight(object sender, PaintEventArgs e)
        {
            if (clicked)
            {
                var g = e.Graphics;
                var b = new SolidBrush(Color.FromArgb(50, 50, 50, 50));
                g.FillRectangle(b, mouse.X, mouse.Y, 50, 50);
    
                clicked = false;
            }
        }
    
        public void trans_MouseClick(object sender, MouseEventArgs e)
        {
            mouse = e.Location;
            trans.Invalidate();
            clicked = true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have small problem with my .net 2.0 winforms application. I want to embed
I have a small .NET WinForms application, and couple of linux servers, DEV and
i have a .net winforms application that i want to be soundless. occasionally when
I have a .net (3.5) WinForms application and want to display some html on
I have a .NET WinForms application with an animated GIF in a PictureBox .
I have a vb.net Winforms application. I also have a compiled help file (chm)
I have a .net WinForms 2.0 application that has an image library of about
I have a WinForms application written in C# for .NET 3.5 that needs to
I'm developing a .NET application that will have both a WinForms and a Silverlight
Consider we have .NET Winforms application or Console Application. Can anyone tell me what

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.