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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:55:20+00:00 2026-05-18T23:55:20+00:00

How do you change which item is outlined in a ListBox? See the following

  • 0

How do you change which item is “outlined” in a ListBox? See the following screenshot for clarification:

Screenshot demonstrating what I mean by “outlined” item as opposed to “selected” item

Background: I want to have a standard multi-select listbox that works normally. Unfortunately, the Windows Forms ListBox (with SelectionMode.MultiExtended) is not fully functional. The missing functionality is that it doesn’t let you select a disjoint set of items by using Ctrl+Arrow keys and Ctrl+Space. (Try it in Windows Explorer to see how it’s supposed to work.) I am trying to subclass ListBox and add this missing functionality. To this end, I intend to respond to Ctrl+Arrow keys in the OnKeyDown protected method, but in order to do so, I need to be able to move the outline without changing the set of selected items. How do I do that?

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

    You can do this by sending the LB_SETCARETINDEX message to the list box:

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    public static extern uint SendMessage(IntPtr hWnd, uint msg, uint wParam, uint lParam);
    
    public const uint LB_SETCARETINDEX = 0x019E;
    public const uint LB_GETCARETINDEX = 0x019F;
    
    [...]
    
    public int OutlineIndex
    {
        get
        {
            return (int) WinAPI.SendMessage(Handle, WinAPI.LB_GETCARETINDEX, 0, 0);
        }
        set
        {
            if (value < 0 || value >= Items.Count)
                throw new ArgumentException("OutlineIndex cannot be negative or greater than the size of the collection.", "value");
            WinAPI.SendMessage(Handle, WinAPI.LB_SETCARETINDEX, (uint) value, 0);
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: myVariable which I want to change into trace(myVariable: + myVariable);
I need to select each list item and change the background image of the
I have an HTML select list which, when an item is selected, must show
I have the following XML which needs deserializing/serializing: <instance> <dog> <items> <item> <label>Spaniel</label> </item>
How can I change the background color of the item which is selected in
I have a listbox in which the item source contains a List(of T) that
Let's say I have many instances of 'Item'. Later, I want to change some
I have a list which contains an item '\n' in it. I want to
I have a background that I would like to change depending on which browser
I have a Select list on my page, and based on which item is

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.