Connecting Tech Pros Worldwide Forums | Help | Site Map

Silly combo box question

Adam Honek
Guest
 
Posts: n/a
#1: May 6 '06
Hi,

I've looked over and over and in MSDN 2005 and just can't find what
is a really simple answer.

How do I select the first value in a combo box to be shown?
I tried the .selectedindex -1 but it doesn't work.

At the moment it populates fine but it just remains blank unless I
dropdown the list.

Thanks,
Adam



Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#2: May 6 '06

re: Silly combo box question


"Adam Honek" <AdamHonek@Webmaster2001.freeserve.co.uk> schrieb:[color=blue]
> I've looked over and over and in MSDN 2005 and just can't find what
> is a really simple answer.
>
> How do I select the first value in a combo box to be shown?
> I tried the .selectedindex -1 but it doesn't work.
>
> At the moment it populates fine but it just remains blank unless I
> dropdown the list.[/color]

Set the 'SelectedIndex' property to 0. Setting it to -1 causes no item to
be selected, which is indicated by the blank combobox.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Cor Ligthert [MVP]
Guest
 
Posts: n/a
#3: May 6 '06

re: Silly combo box question


Adam,

The first is 0 as most things that are derived from classic VB.

If you want an empty box by not binded data than you can use -1.

I hope this helps,

Cor

"Adam Honek" <AdamHonek@Webmaster2001.freeserve.co.uk> schreef in bericht
news:%23gSqZGScGHA.4892@TK2MSFTNGP02.phx.gbl...[color=blue]
> Hi,
>
> I've looked over and over and in MSDN 2005 and just can't find what
> is a really simple answer.
>
> How do I select the first value in a combo box to be shown?
> I tried the .selectedindex -1 but it doesn't work.
>
> At the moment it populates fine but it just remains blank unless I
> dropdown the list.
>
> Thanks,
> Adam
>[/color]


Cor Ligthert [MVP]
Guest
 
Posts: n/a
#4: May 6 '06

re: Silly combo box question


Misreaded your answer therefore I did it again.

Sorry

Cor

"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:%23zqY6MScGHA.380@TK2MSFTNGP04.phx.gbl...[color=blue]
> "Adam Honek" <AdamHonek@Webmaster2001.freeserve.co.uk> schrieb:[color=green]
>> I've looked over and over and in MSDN 2005 and just can't find what
>> is a really simple answer.
>>
>> How do I select the first value in a combo box to be shown?
>> I tried the .selectedindex -1 but it doesn't work.
>>
>> At the moment it populates fine but it just remains blank unless I
>> dropdown the list.[/color]
>
> Set the 'SelectedIndex' property to 0. Setting it to -1 causes no item to
> be selected, which is indicated by the blank combobox.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>[/color]


Adam Honek
Guest
 
Posts: n/a
#5: May 6 '06

re: Silly combo box question


Thanks guys, 0 it is and works like a charm.

Adam

"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:%237BakYScGHA.1208@TK2MSFTNGP04.phx.gbl...[color=blue]
> Adam,
>
> The first is 0 as most things that are derived from classic VB.
>
> If you want an empty box by not binded data than you can use -1.
>
> I hope this helps,
>
> Cor
>
> "Adam Honek" <AdamHonek@Webmaster2001.freeserve.co.uk> schreef in bericht
> news:%23gSqZGScGHA.4892@TK2MSFTNGP02.phx.gbl...[color=green]
>> Hi,
>>
>> I've looked over and over and in MSDN 2005 and just can't find what
>> is a really simple answer.
>>
>> How do I select the first value in a combo box to be shown?
>> I tried the .selectedindex -1 but it doesn't work.
>>
>> At the moment it populates fine but it just remains blank unless I
>> dropdown the list.
>>
>> Thanks,
>> Adam
>>[/color]
>
>[/color]


Jim Wooley
Guest
 
Posts: n/a
#6: May 8 '06

re: Silly combo box question


> Adam,[color=blue]
>
> The first is 0 as most things that are derived from classic VB.
>
> If you want an empty box by not binded data than you can use -1.[/color]

Unless you are talking Dotnet 1.x and currently have a value selected. In
that case, you need to set it to -1 twice (or sometimes 3 times). Actually,
I think the implementation in 2.0 sets the selectedindex to 0 then -1 if
you try to set it to -1 when it is currently > 0, which effectively means
that unselecting a value will cause a value to be selected temporarily and
then unselected. This to me is more silly than the original question which
has already been answered.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx


Newbie
 
Join Date: May 2006
Posts: 5
#7: May 10 '06

re: Silly combo box question


Where can I find SelectedIndex property? in Access combo box, right click and properties, because i couldnt find there? or in VB?
Closed Thread


Similar Visual Basic .NET bytes