Wrox Programmer Forums
|
BOOK: Beginning Microsoft Visual Basic 2010
This is the forum to discuss the Wrox book Beginning Visual Basic 2010 by Thearon Willis, Bryan Newsome; ISBN: 9780470502228
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Microsoft Visual Basic 2010 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 9th, 2011, 11:53 PM
Registered User
 
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default ComboBox Programming

Hi all,

I am currently working through the book beginning VB 2010 and need to implement a code for two combo boxes.
The first combo box (cboCountry) to display and load all the list of countries and the second combo box (cboState) to display and load all the states for each country in cboCountry.
In addition, I want the user to be able to select any country in cboCountry which will automatically load the states for that country in cboState. How do I do this without having to declare every elements in the two combo boxes manually, i.e. Is there a method to call in. NET Framework4 just like the get date method that display current date and time in. NET Framework4 that can do this?
 
Old May 16th, 2011, 08:46 AM
Authorized User
 
Join Date: May 2010
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
Send a message via Yahoo to GeneBuchite
Default LinQ works Great

I would Load all the Countries And States into A Class Named CountryStates, THen Use LINQ to SQL to Fill ComboBox Items.

Code:
 Dim query = From ctry in countryStates

FOr Each cntry IN Query
   cboCountry.Items.Add(cntry.Country)
NExt
Then Fill State After Country Is Selected

Code:
 cboCountry.TExtChanged 

Dim query = From ctry in countryStates Where ctry.Country = cboCountry.Text
cboState.Items.Clear()
FOr Each cntry IN Query
   cboState.Items.Add(cntry.State)
NExt





Similar Threads
Thread Thread Starter Forum Replies Last Post
device DLL programming in client side programming hendyhanusin ASP.NET 1.0 and 1.1 Professional 2 February 19th, 2009 12:01 PM
Outlook 2007 Forms Programming ComboBox Arsi BOOK: Professional Outlook 2007 Programming ISBN: 978-0-470-04994-5 13 December 20th, 2007 03:22 PM
Filling Combobox with value from other Combobox ayazhoda Access VBA 6 June 5th, 2007 04:58 AM
device DLL programming in client side programming hendyhanusin ASP.NET 1.0 and 1.1 Basics 0 March 21st, 2007 08:05 AM
device DLL programming in client side programming hendyhanusin ASP.NET 2.0 Professional 1 March 21st, 2007 08:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.