Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Help required

Help required

Scheduled Pinned Locked Moved Visual Basic
helpcsharpsalestutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    emmshazi
    wrote on last edited by
    #1

    Hello everyone!:) I am new to this site & to VB.NET. I have got following problem. I have 3 listbox and one datagrid control on my form. I have 4 tables like-> Customer,City,Area,Country Relation between these tables is like so: 1 Country --> Many Cities 1 city --> Many Areas 1 Area --> Many Customers Now what I want to do is that when form is loaded then country names are displayed in listbox1, when user selects a country, all cities of that country are displayed in listbox 2, and when user selects a city then its areas are displayed, and finally when user selects an area then customers of that area are displayed in datagrid. I have tried selectedindex property of listbox to solve this problem. Can anyone give me a better suggestion. I'll be thankful if you can help me by providing an example for it, it'll be easier for me to understand it then. Thanx. want to learn.

    G U 2 Replies Last reply
    0
    • E emmshazi

      Hello everyone!:) I am new to this site & to VB.NET. I have got following problem. I have 3 listbox and one datagrid control on my form. I have 4 tables like-> Customer,City,Area,Country Relation between these tables is like so: 1 Country --> Many Cities 1 city --> Many Areas 1 Area --> Many Customers Now what I want to do is that when form is loaded then country names are displayed in listbox1, when user selects a country, all cities of that country are displayed in listbox 2, and when user selects a city then its areas are displayed, and finally when user selects an area then customers of that area are displayed in datagrid. I have tried selectedindex property of listbox to solve this problem. Can anyone give me a better suggestion. I'll be thankful if you can help me by providing an example for it, it'll be easier for me to understand it then. Thanx. want to learn.

      G Offline
      G Offline
      Guillermo Rivero
      wrote on last edited by
      #2

      Try this. Public Structure uListElement Public ID as integer Public Name as string Public Override Function ToString() as String Return Name End Function End Structure Now, fill the listbox1 with this structure, where each element in the structure is a ListElement, e.g. Dim vElement as uListElement vElement.ID=CountryCode vElement.Name=CountryName ListBox1.Items.Add(uListElement) In the ListBox1 SelectedIndexChanged event, cast the SelectedItem into a uListItem and you can get the ID of the selected country. Once you have the element, you can execute a select on the datatable of the cities that belongs to the country you just selected. Then you can repeat the same for the Areas and Customers... Got the idea ? Free your mind...

      1 Reply Last reply
      0
      • E emmshazi

        Hello everyone!:) I am new to this site & to VB.NET. I have got following problem. I have 3 listbox and one datagrid control on my form. I have 4 tables like-> Customer,City,Area,Country Relation between these tables is like so: 1 Country --> Many Cities 1 city --> Many Areas 1 Area --> Many Customers Now what I want to do is that when form is loaded then country names are displayed in listbox1, when user selects a country, all cities of that country are displayed in listbox 2, and when user selects a city then its areas are displayed, and finally when user selects an area then customers of that area are displayed in datagrid. I have tried selectedindex property of listbox to solve this problem. Can anyone give me a better suggestion. I'll be thankful if you can help me by providing an example for it, it'll be easier for me to understand it then. Thanx. want to learn.

        U Offline
        U Offline
        User 765502
        wrote on last edited by
        #3

        In order to solve your problem you need to do the following steps. try to use procedures always 1)write a code for filiing countries name and can be placed in form load event. 2)write a code in that pass sql query as <select cityID,city from city where cityID=cmbcountryfilled.selectedvalue> and place this code in selection change commited event of country combo.and do the same for area.i ohope it will work. before that it depends how you are filling the combo.try to use dataset and fill the combo. please get back to me if you have any doubt...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups