Home All Groups Group Topic Archive Search About

Bound combo box problem

Author
11 Apr 2005 4:16 AM
J L
I hope this does not post twice. I got an error on the first attempt.

I have a combo box on a form with DropDownStyle = DropDownList

I have bound it as follows:

cmboOp.DataSource = opTable
cmboOp.DisplayMember = "OperatorName"
cmboOp.ValueMember = "OperatorID

The binding works fine. I put a test button on the form that does the
following:

cmboOp.SelectedIndex = -1

The first time I click the button, the combo box displays the first
item in the list. The second time it is blank.

I had expected it to be blank on the first time. So what is going on
or what have I done wrong?

TIA,
John

Author
11 Apr 2005 6:10 AM
Cor Ligthert
JL,

I thought that this has been in past often in the newsgroup. Can you try to
set it twice to "-1", there was a bug which had this behaviour, however I
don't know if it is fixed with sp1 and/or that it is exactly your problem.

I hope this helps,

Cor
Author
11 Apr 2005 9:36 AM
Herfried K. Wagner [MVP]
Show quote Hide quote
"J L" <j***@marymonte.com> schrieb:
> I have a combo box on a form with DropDownStyle = DropDownList
>
> I have bound it as follows:
>
> cmboOp.DataSource = opTable
> cmboOp.DisplayMember = "OperatorName"
> cmboOp.ValueMember = "OperatorID
>
> The binding works fine. I put a test button on the form that does the
> following:
>
> cmboOp.SelectedIndex = -1
>
> The first time I click the button, the combo box displays the first
> item in the list. The second time it is blank.

BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1
<URL:http://support.microsoft.com/?scid=kb;EN-US;327244>

Try setting 'SelectedIndex' twice.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
11 Apr 2005 1:31 PM
J L
Thanks Cor and Herfried,
I thought I had tried setting it twice but I guess not because that
works fine. Also, I did try a google search before trougling the group
with an old question but could not find the link you supplied. So once
again, thank you to the Gurus!!

John

On Mon, 11 Apr 2005 11:36:39 +0200, "Herfried K. Wagner [MVP]"
<hirf-spam-me-here@gmx.at> wrote:

Show quoteHide quote
>"J L" <j***@marymonte.com> schrieb:
>> I have a combo box on a form with DropDownStyle = DropDownList
>>
>> I have bound it as follows:
>>
>> cmboOp.DataSource = opTable
>> cmboOp.DisplayMember = "OperatorName"
>> cmboOp.ValueMember = "OperatorID
>>
>> The binding works fine. I put a test button on the form that does the
>> following:
>>
>> cmboOp.SelectedIndex = -1
>>
>> The first time I click the button, the combo box displays the first
>> item in the list. The second time it is blank.
>
>BUG: ComboBox Does Not Clear When You Set SelectedIndex to -1
><URL:http://support.microsoft.com/?scid=kb;EN-US;327244>
>
>Try setting 'SelectedIndex' twice.