Results 1 to 12 of 12
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Drop-down Listbox (VS.NET 2003)

    Does anyone have the code necessary to convert a combobox to a dropdown listbox. There seems to be a drop-down listbox for Web applications, but not for a Window's application. I would prefer C#, but I can easily translate VB. TIA! --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drop-down Listbox (VS.NET 2003)

    What do you mean by "convert"? The System.Web.UI.WebControls.DropDownList is a different control than the System.Windows.Forms.ComboBox. There's not really any converting between the two, even though they share some similarities.

    Check out Microsoft's help topic on Combo Box for more specifics...

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Drop-down Listbox (VS.NET 2003)

    In the old pre-.Net days, a ComboBox was a drop-down listbox

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Drop-down Listbox (VS.NET 2003)

    I am setting the DropDownStyle to DropDownList: it's OK but not very nice. For example, if my item list is AAA, ABC, and BBB and if I type ab, I would like the list to drop-down and ABC to be selected. Instead, the textbox portion is filled with BBB and the list is not dropped. I can live with it, but it's ugly.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Drop-down Listbox (VS.NET 2003)

    If you get some free time to play, maybe you can combine this event and method to get the effect you want:

    Control.TextChanged Event (System.Windows.Forms)
    ComboBox.FindString Method (System.Windows.Forms)

    (I noticed documentation on an Autocomplete feature in .Net 2.0, but it's not clear it works with a drop-down list.)

  6. #6
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drop-down Listbox (VS.NET 2003)

    Thanks! <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> I was too afraid to ask... but it's been something the users have been <img src=/S/crybaby.gif border=0 alt=crybaby width=15 height=15> ing about for the past few months.
    Carpy Diem, it&#39;s .

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Drop-down Listbox (VS.NET 2003)

    That's standard for dropdowns in .Net. You can force a dropdown in code, but is it really necessary? Usually if a user is typing in a value in a dropdown, they know what they're looking for, which is why they didn't click the dropdown arrow. Just my <img src=/S/2cents.gif border=0 alt=2cents width=15 height=15>
    Charlotte

  8. #8
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Drop-down Listbox (VS.NET 2003)

    I'm living with the default interaction for now, but it is one of those annoying long drop-downs which contains the 3-letter codes for all of the countries in the world, so it would easier to type in the first two letters and then click on the country which would then be visible. We usually know the code for most of the countries that we deal with, but I've used a drop-down list to keep them from fat-fingering a non-existent country.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  9. #9
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drop-down Listbox (VS.NET 2003)

    Charlotte,
    Yes - logically speaking, someone would know the name, but darn those pesky end-users... <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>
    Carpy Diem, it&#39;s .

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Drop-down Listbox (VS.NET 2003)

    You can use limit to list to prevent non-existent countries. A list that long would be annoying as a dropdown, I think, and you do get some odd behavior when you get to the bottom of a dropdown list..
    Charlotte

  11. #11
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Drop-down Listbox (VS.NET 2003)

    I don't have a limit to list property. That would be nice. I'm just using Framework 1.1. Maybe this is a property in 2.0. But, that is the way to go: when I create an ErrorProvider on the form, I'll just check to make sure that cbo.text is in cbo.items. Thanks for the suggestion! --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  12. #12
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Drop-down Listbox (VS.NET 2003)

    I didn't mean there was a limit to list property, I meant you could create a limit to list handler for the control in its validating event that would check to see if the item was in the list.
    Charlotte

Posting Permissions

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