Help required
-
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.
-
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.
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...
-
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.
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...