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,
09-07-2001, 01:54 AM
GJ
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,
>
>
09-07-2001, 03:06 AM
Stan Shankman
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,
> >
> >
>