|
-
Jan 20th, 2011, 08:34 AM
#1
Thread Starter
Lively Member
-
Jan 20th, 2011, 12:23 PM
#2
Re: Th information in a ComboBox and reference to a database???

The way I would approach it would be to just populate the first combobox with the values from the table.
Then, after the user selects the value for combobox1, go back to the database and extract all values from the table except the one just selected, and put those values in combobox2.
When the user selects a value from combobox2, then populate combobox3 with all the values from the database minus the two selected.
You can continue this pattern on down the line.
You may also want to make sure all the comboboxes below the one you populate have their item lists cleared. That way, if a user is on the 5th combobox and decides to jump back to the second one and make a selections, then the 4th and 5 boxes will have their selections cleared.
This is assuming that the user needs to follow a top-down progression on the list. If the user can jump from any combobox to another, then it would have to be handled differently.
 I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Jan 24th, 2011, 03:21 AM
#3
Thread Starter
Lively Member
Re: Th information in a ComboBox and reference to a database???
 Originally Posted by dolot

The way I would approach it would be to just populate the first combobox with the values from the table.
Then, after the user selects the value for combobox1, go back to the database and extract all values from the table except the one just selected, and put those values in combobox2.
When the user selects a value from combobox2, then populate combobox3 with all the values from the database minus the two selected.
You can continue this pattern on down the line.
You may also want to make sure all the comboboxes below the one you populate have their item lists cleared. That way, if a user is on the 5th combobox and decides to jump back to the second one and make a selections, then the 4th and 5 boxes will have their selections cleared.
This is assuming that the user needs to follow a top-down progression on the list. If the user can jump from any combobox to another, then it would have to be handled differently.
I tried to do this, but got an error every way i tried...
I made a new TableAdapter in which I populated the info from the database MINUS the information chosen in the ComboBox above... So basically the query was the same as for the Box above, but I added a requirement for the where clause...
Code:
WHERE ........... dbo.List.NameColumn <> @NameInBox1
Then when populating the info in VB, the code recuires me to assign the @NameInBox1.....
Code:
NameInox1:=ComboBox1.Text
That way seemed very logical to me, but I get an error:
"Object reference not set to an instance of an object."
-
Jan 25th, 2011, 08:36 AM
#4
Re: Th information in a ComboBox and reference to a database???
 Originally Posted by Hamsori
That way seemed very logical to me, but I get an error:
"Object reference not set to an instance of an object."
That means that one of the variables or properties you're accessing is set to nothing. Once you determine which one it is you can better address the problem. My suspect is the 'Text' property of combobox1, but I can't say for sure.
 I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Jan 25th, 2011, 08:45 AM
#5
Frenzied Member
Re: Th information in a ComboBox and reference to a database???
say you have selected Name_1 in combobox1, then for the remaining cmbxs just do a FindStringExact and remove the item by using the Index returned the FindStringExact function
But, this method is not feasible is the selected value in any of the combobox is changed
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|