Results 1 to 6 of 6

Thread: [RESOLVED] How do you make an item in a comboBox not selectable?

  1. #1

    Thread Starter
    Addicted Member zahadumy's Avatar
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    187

    Resolved [RESOLVED] How do you make an item in a comboBox not selectable?

    In a comboBox I would like to have something like:

    aaa
    bbb
    ccc
    ---
    ddd
    eee
    ---
    fff

    and I would like the user not to be able to select a "---" line. Thank you.
    The first step in solving a problem is to define the problem clearly.

    -----
    Icons | EZIconConverter | Popup Messages
    101 samples: 2003 2005
    Code converter: C# -> VB .NET | VB .NET -> C# | VB .NET <-> C#


    -----
    Visual Studio 2005/.NET Framework 2.0

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: How do you make an item in a comboBox not selectable?

    in the selectedindex changed event put code to check to see what the user selected, if they selected --- then either move to another item, or set the selectedindex to -1

    VB Code:
    1. If combobox1.text = "---" then
    2.     combobox1.selectedindex = -1
    3. end if

  3. #3

    Thread Starter
    Addicted Member zahadumy's Avatar
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    187

    Re: How do you make an item in a comboBox not selectable?

    Umm... I didn't make myself clear... When you click the comboBox, the list of items is displayed. When you move the cursor to an item, it gets highlighted. I would like when I move my cursor to a "---" line, that line not to get highlighted, and the user realize he cannot select that line. Is this possible?
    I hope I explained it well this time... Sorry about my english.
    The first step in solving a problem is to define the problem clearly.

    -----
    Icons | EZIconConverter | Popup Messages
    101 samples: 2003 2005
    Code converter: C# -> VB .NET | VB .NET -> C# | VB .NET <-> C#


    -----
    Visual Studio 2005/.NET Framework 2.0

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    35,242

    Re: How do you make an item in a comboBox not selectable?

    Never heard of that, I doubt it can be done with the standard combobox, but maybe somebody knows some solution. I have the faintest memory that you could add a spacer to a combobox list like you can add a spacer to a menu list, however, I don't know if the faint memory is correct or not.
    My usual boring signature: Nothing

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,461

    Re: How do you make an item in a comboBox not selectable?

    The Code Project would be the first place I'd look for something like that. An article search for "ComboBox" should yield a bunch of owner-drawn ComboBox examples.

  6. #6

    Thread Starter
    Addicted Member zahadumy's Avatar
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    187

    Re: How do you make an item in a comboBox not selectable?

    Oka, I thought it would be possible to do this with the default comboBox, I won't write my own control only for this, because it's not that important... Thank you.
    The first step in solving a problem is to define the problem clearly.

    -----
    Icons | EZIconConverter | Popup Messages
    101 samples: 2003 2005
    Code converter: C# -> VB .NET | VB .NET -> C# | VB .NET <-> C#


    -----
    Visual Studio 2005/.NET Framework 2.0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width