xswzaq

I really really need help. I am working on the project that have 3 list box. I want to perform search so that users easily access data they want. In my listbox1, users will choose his/her choice, then the listbox2 (blank before user enter choice in listbox1) will automaticly pop up a list. For example, if I selected QA in listbox1, only catagories (item in QA) should show in listbox 2 (not all), and if I select RA only item in RA will be showing (no QA choice be shown here) and then I will click Search button for the pick choice. Is there possibly a way to do it I appreciate any help.

Re: Visual Basic Language SelectedIndexChanged

rkimble

This can be accomplished easily using databinding if the ListBoxes are bound to a dataset that has the appropriate relationship defined.

Is your data coming from a relational DataSet





Re: Visual Basic Language SelectedIndexChanged

Angel_LL

I link my listbox to the data (warehouse colume) that I have on the table, and all of my table are under one dataset. One more things, right now i am working on a combine table. I got three table that I put under one datagrid. Is this going to affect anything



Re: Visual Basic Language SelectedIndexChanged

rkimble

Ok, here's the VS2005 method in a nutshell:

  1. Add two BindingSource components to the form.
  2. The first one should have the DataSource set to the DataSet instance on the form, and the DataMember set to the DataTable which is the parent in the relationship
  3. The second BindingSource should have the DataSource set to the first BindingSource and the data member set to the relationship name
  4. Then you bind the first listbox to the first bindingsource and the second to the second.
Now when you select an item in the first bindingsource, only related items will appear in the second bindingsource.






Re: Visual Basic Language SelectedIndexChanged

Angel_LL

I will try you method. Thank you.



Re: Visual Basic Language SelectedIndexChanged

Angel_LL

Your method is not quite what I want. You method is to selected the line across the pick choice, not for user to have a choice and pick again. Because in my datagridview, there are hundreds of data. There are QA, RA, RE, etc... And in QA, there are MP1, MP2, MP3..., and on RA, there are 41H0, 42H1, 43H2... What I want is if users pick QA, the choice MP1, MP2, MP3... will automatically show up and users will then pick for the choice MP1, MP2 or MP3... to narrow down the search.





Re: Visual Basic Language SelectedIndexChanged

rkimble

What you are describing is accomplished as I explained. You must simply set up the binding as needed.

BindingSource1 should have its DataSource set to the table that contains QA, RA, RE, etc. And then BindingSource2 should have its DataSource set to BindingSource1 and its DataMember set to the name of the relationship that connects to the table containing MP1, MP2, MP3, 41H0, 41H1, etc. Then, if there is a third table with a relationship to the second table, you create a thrid BindingSource that has its DataSource set to BindingSource2 and its datamember set to that relationship.

In this way you would have listbox1-bindingsource1 for the user to select the parent item, which would display the related items in listbox2, and selecting one of those would show the items related to the item in listbox2 in whatever contol you choose - another listbox or combobox or whatever.

If that doesn't fit you're need, try to better describe your dataset schema.

Hope that helps.






Re: Visual Basic Language SelectedIndexChanged

Angel_LL

I have listbox1 connected to the column WareHouse in my datagridview as Bindingsource1, and my listbox2 connect to the column Location as Bindingsource2 (under same datagridview). When I am using your method, it only select the line accross the choice that I pick, but all other choice in listbox2 disappear (I know in QA should have at least 5 to 6 other choice, but it all disappear). It only select the line accross it. I am using everything from one datagridview which under one dataset. By the way I am using two different table into onr datagridview. Column Warehouse is in WarehouseSearch Table, and Column Location is in LocationSearch Table. Is this effect what I am doing



Re: Visual Basic Language SelectedIndexChanged

rkimble

This is still just a matter of setting up the binding correctly. But I can't get a clear picture of how your database looks and which controls are bound to which table.

First, please describe the DataSet:

  • List each table name
  • List important column names for each table
  • Describe the relationships between the tables that are defined in the DataSet

Next, describe the controls in the user interface:

  • List each control by Type (ListBox1, ListBox2, DataGrid1, etc.)
  • Pair each control with the table or relationship that should provide the data
  • List the columns that should be displayed per control

Finally, try to better describe the process that the user would go through in order to use this form.

If you make the intended design more clear, we should be able to determine how the controls need to be bound to suit your purpose - or we'll discover that your database and/or logic need to be redesigned.






Re: Visual Basic Language SelectedIndexChanged

Angel_LL

FIRST: I have 4 table (1. PART 2. LOCATION 3.WAREHOUSE 4. LOT).

I take:

ID column from PART

Date/Time column and warehouse column from WAREHOUSE

Location column from LOCATION

Lot_no from LOT

ALL OF THESE TABLE HAVE RELATES WITH EACH OTHER, THERE ALSO SOME COLUMN THAT HAVING EXACTLY INFORMATION (but I do not use/show in my datagridview)

I combine all those columns mention above and put it under one datagridview

SECOND: I use bindingsouce so that warehouseListBox will read Warehouse column (from datagridview) and display value so user can pick their choice, same thing with listbox2 for Location.

This is where I get the problem. In my form there are two list boxt, and two text box, searchbtn, and closebth (for now let not worried about textbox and closebtn). listbox1 is warehouseListBox, and listbox2 is locationListBox. (When I user bindingsource, it read the whole column even which the repeat words. I am trying to figure out a way to get it of the repeat words/choice). Get back to the listbox, in warehouseLstBox there should be QA, RA, FLOOR, ect... and In QA, there should be other choice like MP1, MP2, MP3...(same thing with RA, choice 41H0, 42H1, 43H2... ). If user choose QA, I want MP1, MP2, MP3... choice to show up and user can choose again. For example, if user choose QA and MP1 and when they click searchbtn, only WareHouse column with QA and MP1 in LOCATION column should show up on the datagridview.

I hope that I don't confuse you

Thank you all for your guidance





Re: Visual Basic Language SelectedIndexChanged

rkimble

Are you describing your dataset or database You keep saying "combine into one datagridview" - do you mean that you are using InnerJoins in your SELECT statement

You need to have all four tables in the DataSet designer. You need to specify the relationships in the DataSet designer. It sounds like you may only have 1 table in the dataset that is pulling data from multiple tables in the database using inner joins in the select statement...






Re: Visual Basic Language SelectedIndexChanged

Angel_LL

That is true, I use Select statement to select everything and I only have one table in dataset which pull all data from multiple table.