Selamat Sore,
What have you done, and tried so far ?
Have you created two ComboBoxes, filled them with Items, and made sure you understand how to change what's in the second ComboBox by using an EventHandler you've created for the first ComboBox for one of these events: SelectedIndexChanged, SelectedValueChanged, or SelectionChangeCommitted ?
Perhaps, consider parsing simple Text files to hold the contents of the second ComboBox item-sets. One separate file for each of the different groups ?
~
Visual Studio and the Designer.cs file it produces (C#, WinForms) can be a great asset to you here: after you drag-drop a first ComboBox onto a Form, context-click on it, and select "Edit Items:" then type in a bunch of entries, separated by carriage returns. Close that item-editor.
Then,open the Designer.cs file: click on the little rectangle with the "+" sign to expand the region titled "Windows Form Designer generated code."
You'll see that the way that Items are added to a ComboBox looks something like this:
this.cmbPrimary.Items.AddRange
(
new object[]
{
"Category1",
"Category2",
"Category3"
}
);
That shows you clearly the form your different item-sets for the second ComboBox are going to have to be in, and you are going to have to get your data, whatever its source, into that form. There are many ways to do that.
~
Personally, I would probably store all the Item-set data in either one Text file, or, perhaps one XML format file, and then parse it: so, I'd build an object like this:
List<Object[]> SecondaryComboBoxItems = new List<object[]>()
{
new object[] { "Item 1", "Item 2", "Item 3", "Item 4" },
new object[] { "Item 1a", "Item 2a", "Item 3a", "Item 4a"},
new object[] { "Item 1b", "Item 2b", "Item 3b", "Item 4b"}
};
This gives me a List, each Item of which is an Array of Objects where each object in a given array is a string.
So, I could just use an integer index (in this case #0~2) to get the right Items into the secondary ComboBox.
~
The Database issue: if you use a DataBase, one thing you probably don't want to do is: every time the selection in the first ComboBox changes you must pull-down the data again: in your scenario here, you are probably not talking about such "massive data" that you would need to, possibly, do this.
So, if you use a DataBase: how can you get all the different groups of whatever that will go into the second ComboBox's Item-sets, and store ("cache") them: so switching between Item-sets in the second ComboBox, as the selected Item in the first ComboBox changes: is fast ?
This is not difficult, and is a good problem for you to solve.
~
If you break down this challenge into steps, as I've tried to illustrate here (this is called the "divide and conquer" strategy" by some teachers of programming), and solve each step:
You will learn a set of skills that you can then apply to many different future problems, and my goal in this response is to get you to work on that, not just telling you how to write the code.
Baik baik saja ?
good luck, Bill