comboBox question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: comboBox question

Hybrid View

  1. #1
    Stan Shankman Guest

    comboBox question

    Greetings all,



    I have a question about comboBox.



    Using Visual Studio Beta 2, and C# in a Windows Application, I notice that
    when my code is first run (i.e. before the comboBox is ever used) - the text
    displayed in the comboBox is that of the "Text Property". However, once a
    selection is made, the comboBox (by default) is left with the selected item'
    s text. Well that's fine, but what I want is to programmatically redisplay
    it's original text - I would think that comboBox.Text would do the trick,
    but it doesn't. Or, maybe comboBox.SelectedIndex = -1 would work but it
    doesn't. Try it. I'm assuming that a comboBox is called a comboBox because
    it's a combination of a listBox and a textBox. But I'm not seeing the
    textBox functionality. What am I missing here?

    Anyone?



    Thanks guys,



  2. #2
    GJ Guest

    Re: comboBox question


    I think you need to set the selected index to 0, not -1.
    Also, I'm not sure about the textbox functionality... I've never used it
    that way. Usually I set the items in the Items indexer to whatever object
    I'm using. The thing will call the ToString method of your object to display
    text in the combobox.

    "Stan Shankman" <stantheman@visi.com> wrote:
    >Greetings all,
    >
    >
    >
    >I have a question about comboBox.
    >
    >
    >
    >Using Visual Studio Beta 2, and C# in a Windows Application, I notice that
    >when my code is first run (i.e. before the comboBox is ever used) - the

    text
    >displayed in the comboBox is that of the "Text Property". However, once

    a
    >selection is made, the comboBox (by default) is left with the selected item'
    >s text. Well that's fine, but what I want is to programmatically redisplay
    >it's original text - I would think that comboBox.Text would do the trick,
    >but it doesn't. Or, maybe comboBox.SelectedIndex = -1 would work but it
    >doesn't. Try it. I'm assuming that a comboBox is called a comboBox because
    >it's a combination of a listBox and a textBox. But I'm not seeing the
    >textBox functionality. What am I missing here?
    >
    >Anyone?
    >
    >
    >
    >Thanks guys,
    >
    >



  3. #3
    Stan Shankman Guest

    Re: comboBox question

    GJ,



    Thanks for the reply.



    I have tried comboBox.SelectedIndex = 0 but it won't do it. Remember, the
    items in the comboBox drop-down are in an array, and it is zero based. Zero
    just references the first item.



    I have played with this for a while, and I haven't figured it out.



    Yet clearly when the control is first displayed, it has responded to the
    comboBox.Text statement.



    If anyone can figure out how to place test in the "text box portion" of a
    comboBox

    I would sure like to hear from you.

    -Stan Shankman



    "GJ" <star_screamer@hotmail.com> wrote in message
    news:3b986102$1@news.devx.com...
    >
    > I think you need to set the selected index to 0, not -1.
    > Also, I'm not sure about the textbox functionality... I've never used it
    > that way. Usually I set the items in the Items indexer to whatever object
    > I'm using. The thing will call the ToString method of your object to

    display
    > text in the combobox.
    >
    > "Stan Shankman" <stantheman@visi.com> wrote:
    > >Greetings all,
    > >
    > >
    > >
    > >I have a question about comboBox.
    > >
    > >
    > >
    > >Using Visual Studio Beta 2, and C# in a Windows Application, I notice

    that
    > >when my code is first run (i.e. before the comboBox is ever used) - the

    > text
    > >displayed in the comboBox is that of the "Text Property". However, once

    > a
    > >selection is made, the comboBox (by default) is left with the selected

    item's
    > >text. Well that's fine, but what I want is to programmatically redisplay
    > >it's original text - I would think that comboBox.Text would do the trick,
    > >but it doesn't. Or, maybe comboBox.SelectedIndex = -1 would work but it
    > >doesn't. Try it. I'm assuming that a comboBox is called a comboBox

    because
    > >it's a combination of a listBox and a textBox. But I'm not seeing the
    > >textBox functionality. What am I missing here?
    > >
    > >Anyone?
    > >
    > >
    > >
    > >Thanks guys,
    > >
    > >

    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center