Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Comboboxes and Listboxes - Deciding Between Them
"Bookreader" <bookreader127@yahoo.com> wrote in message
 news:9f8jt1h0a6hnql5oapc1uatsp51dvpk4r3@
4ax.com...
>I have been playing around with listboxes and comboboxes trying to
> figure something out.
>
> Please correct me where I am wrong.  Some things I thought were true
> may not be.
>
> I always thought that comboboxes were inherited from listboxes.
> Therefore, I thought that comboboxes would have all the properties and
> methods of listboxes.
>
> The current case is that I have a list of items of which the user  is
> only allowed to pick one.
>
> In a listbox, I can set the MultiSelect Property to '0' (none) and
> then show the item selected by simply:
>
>     MsgBox lstFamilies.List(lstFamilies.ListIndex)
>
> This will show me which item was selected.
>
> On the other hand, I like the combo box. Here, I can get it with the
> ComboBox.Text method.
>
> Is the combobox not a descendant of the listbox?


No, it's not.  Each is a distinct and separate control.  VB's ListBox and
ComboBox controls are derived from controls that are built-in to Windows.
See the following documentation topics for each:

http://msdn.microsoft.com/library/e...r />
boxes.asp
http://msdn.microsoft.com/library/e...
xes.asp

The Text property of a ComboBox returns whatever is assigned to the edit box
of the control.  Since a ListBox doesn't have an edit box, there's no Text
property.  This may or may not match the text of an item that's been added
to the ComboBox. For a "Listbox-like" ComboBox, set the CB's Style property
to 2- Dropdown List.

If you really wanted to, you *could* wrap the ListBox in a UserControl and
provide a Text property.  Probably more trouble than it's worth unless you
also add even more functionality to it.

--
Mike
Microsoft MVP Visual Basic



Report this thread to moderator Post Follow-up to this message
Old Post
MikeD
01-27-06 12:55 PM


Re: Comboboxes and Listboxes - Deciding Between Them
I don't know where you two bought your copies of VB from, but I know my one
HAS a Text property for ListBoxes which returns the content of the selected
item.

Regards
Dave O.

"MikeD" <nobody@nowhere.edu> wrote in message
news:uBHOuzyIGHA.2320@TK2MSFTNGP11.phx.gbl...
>
> "Bookreader" <bookreader127@yahoo.com> wrote in message
>  news:9f8jt1h0a6hnql5oapc1uatsp51dvpk4r3@
4ax.com... 
>
>
> No, it's not.  Each is a distinct and separate control.  VB's ListBox and
> ComboBox controls are derived from controls that are built-in to Windows.
> See the following documentation topics for each:
>
> http://msdn.microsoft.com/library/e.../>
boboxes.asp
> http://msdn.microsoft.com/library/e...r />
boxes.asp
>
> The Text property of a ComboBox returns whatever is assigned to the edit
> box of the control.  Since a ListBox doesn't have an edit box, there's no
> Text property.  This may or may not match the text of an item that's been
> added to the ComboBox. For a "Listbox-like" ComboBox, set the CB's Style
> property to 2- Dropdown List.
>
> If you really wanted to, you *could* wrap the ListBox in a UserControl and
> provide a Text property.  Probably more trouble than it's worth unless you
> also add even more functionality to it.
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Dave
01-27-06 11:56 PM


Re: Comboboxes and Listboxes - Deciding Between Them
On Fri, 27 Jan 2006 14:57:39 -0000, "Dave" <nobody@nowhere.com> wrote:

>I don't know where you two bought your copies of VB from, but I know my one
>HAS a Text property for ListBoxes which returns the content of the selected
>item.
>
>Regards
>Dave O.

You're right.  I wrote that on the fly after a frustrating several
hours of coding.

Text property was not a good example.

I think we did resolve that the combobox is not descended from the
list box.

Thanks for your reply.

Bookreader

Report this thread to moderator Post Follow-up to this message
Old Post
Bookreader
01-27-06 11:56 PM


Re: Comboboxes and Listboxes - Deciding Between Them
"Dave" <nobody@nowhere.com> wrote in message
news:eJHZFI1IGHA.3192@TK2MSFTNGP10.phx.gbl...
>I don't know where you two bought your copies of VB from, but I know my one
>HAS a Text property for ListBoxes which returns the content of the selected
>item.

How about that.  It most certainly does.  Goes to show how much I ever use a
ListBox.  <g>  Actually, I don't think anything I've written in the last 4
or 5 years has ever used a ListBox.  Live and learn.

--
Mike
Microsoft MVP Visual Basic



Report this thread to moderator Post Follow-up to this message
Old Post
MikeD
01-27-06 11:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:12 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.