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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:07:00+00:00 2026-05-13T12:07:00+00:00

I am creating a custom combobox which can draw separators. So, I override OnDrawItem()

  • 0

I am creating a custom combobox which can draw separators. So, I override OnDrawItem() and OnMeasureItem() methods.
The problem is that OnMeasureItem() is called only once when datasource is changed. So if I want to specify a separator item later I need to remeasure it’s height (because items with separator should be taller), but it seems that all methods that can lead to item height being remeasured are private, so I can’t call them.
I don’t know if it’s easy to understand what I’ve written above, so I will repeat what I need:
I need to remeasure item height (OnMeasureItem() must be called) each time when I specify that the item should be drawn with a separator.

separatorableComboBox.DataSource = customers;
// and now I want the third customer in the list to be drawn with a separator, 
// so it needs to be taller and therefore OnMeasureItem() should be called
separatorableComboBox.SpecifySeparatorItem(customers[2]);

UPD. Guys, calling RefreshItems() works, but it’s very slow (> 20 ms on my machine), are there faster methods?
UPD2. Right now I am using SendMessage(…, CB_SETITEMHEIGHT, …); method as serge_gubenko advised. But I’m just curious if there is a fast way of accomplishing the task with .NET (or more specifically with ComboBox class itself)?

  • 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-13T12:07:00+00:00Added an answer on May 13, 2026 at 12:07 pm

    Just to clarify, I assume you’re using OwnerDrawVariable style for your combobox. If I understood your question correctly, there are couple of ways to do what you need:

    • Call RefreshItems method of the combobox which would recreate items and trigger onMeasureItem event for each item. This method is protected for the ComboBox class, so below is an example on how you could do it using reflection:
        MethodInfo method = comboBox1.GetType().GetMethod(
            "RefreshItems", BindingFlags.Instance | BindingFlags.NonPublic);
        if (method != null) method.Invoke(comboBox1, null);
    
    • Send the CB_SETITEMHEIGHT message to the control with the new height of the item whenever you want to change it:
        public const int CB_SETITEMHEIGHT = 0x0153;
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
        ...
        // this will set height to 100 for the item with index 2 
        SendMessage(comboBox1.Handle, CB_SETITEMHEIGHT, 2, 100); 
    

    Hope this helps, regards

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

Sidebar

Related Questions

I am creating a custom WPF control class which inherits from ComboBox. As I
I'm creating a custom control with a property that can take value from a
I'm often creating custom assertion methods for my JUnit tests. eg: public void assertArrays(String[]
I'm creating custom forum software for a site I'm building, which includes 2 tables
In WPF, we are creating custom controls that inherit from button with completely drawn-from-scratch
I'm looking for a tutorial that explains creating custom usercontrols in WPF. I want
So yes I'm very new to creating my own custom events. I can do
I am facing some troubles creating a Silverlight custom control - a combobox with
I'm creating custom control that contain multiple parts. Inside template creation I'm subscribing for
while creating custom item renderers which interfaces we need to implement? Thank in advance.

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.