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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:51:19+00:00 2026-05-20T05:51:19+00:00

I’m writing some custom behavior for a ToolStripDropDown control. I’d also like to modify

  • 0

I’m writing some custom behavior for a ToolStripDropDown control. I’d also like to modify the ToolStripDropDownButton itself to display a colored shape.

I see that I can handle the Paint event and draw whatever I like. However, is there any way to have the button paint the default background before I paint the shape? It would be hard to get the background exactly right, especially with future versions of .NET and Windows.

In plain ol’ Windows, I could invoke the default proc handler before or after my paint code. I’m not seeing any way to accomplish that in .NET. Or perhaps there’s a way to tell the button to paint only the background?

  • 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-20T05:51:20+00:00Added an answer on May 20, 2026 at 5:51 am

    When you handle the Paint event (as opposed to overriding the OnPaint method in a derived class) the base class (default proc handler) is already getting called. Everything gets drawn as normal, and then you’re essentially drawing on top of that in the Paint event. You can see that clearly here:

         Lime rectangle drawn over part of the drop-down button, clearly showing the default contents underneath

    The trick is making sure that you leave enough of the control’s clipping rectangle exposed to show the part you want. The e.ClipRectangle property retrieves the entire button’s client area, so if you just
    fill that with a color swatch, you’re going to cover up the drop-down arrow and default background, too. The above demonstration was created using the following ugly sample code:

    private void ToolStripDropDownButton1_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.FillRectangle(Brushes.Chartreuse,
                                 e.ClipRectangle.X + 3, e.ClipRectangle.Y + 3,
                                 e.ClipRectangle.Width - 12,
                                 e.ClipRectangle.Height - 12);
    }
    

    Other than that, I don’t think there’s a way to customize what exactly gets drawn by the base class. Owner-drawing (at least in WinForms) tends to be an all-or-nothing affair. You get complete control,
    but it comes at the price of having to implement everything yourself.

    Of course, in case you haven’t already noticed, the ToolStrip control already doesn’t look like a native Windows control. And even worse, it is always going to look exactly the same as it does now,
    even in future versions of Windows that completely overhaul the UI. (The MenuStrip is plagued by
    this same phenomenon, and the difference is very visible in Windows Vista/7 where the standard API menus have changed dramatically). The reason is that both controls are drawn entirely in C# code written in their WinForms implementations. Personally, I think it looks ridiculously cheesy, and wouldn’t use it in one of my applications on a bet.

    You can assign a custom renderer that uses the UxTheme API to draw the buttons, which will get much closer to approximating the look of the native menus and toolbars. A pretty thorough sample is available here. I’ve written something very similar for the WinForms development that I’ve done requiring the additional features of the ToolStrip class (such as embedding combo boxes) not offered by the
    old-school MainMenu and ToolBar controls that simply wrap their Windows API equivalents. By choosing to do things this way, you do have more control over exactly what parts of the base class renderer you wish to call, as you’ve written the code explicitly yourself. Highly recommended if you’re
    the type that cares at all about UI, native feel, or user experience.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into

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.