Code Comments
Programming Forum and web based access to our favorite programming groups."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
Post Follow-up to this messageI 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 > >
Post Follow-up to this messageOn 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
Post Follow-up to this message"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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.