Hello Scott Steinman,
Thank you for writing. Since your requirement is not to have multiple collections you can consider using two
DataView objects. In the DataView you can set a filter expression on the combo box that displays a subset of items. Here is how you can do this:
public
partial
class
Form1 : Form
{
DataTable mainTable =
null
;
DataView subView =
null
;
public
Form1()
{
InitializeComponent();
mainTable =
this
.CreateTable();
subView =
new
DataView(mainTable);
string
displayMember =
"Name"
;
string
valueMember =
"Value"
;
this
.radComboBox1.DisplayMember = displayMember;
this
.radComboBox1.ValueMember = valueMember;
this
.radComboBox1.DataSource = mainTable.DefaultView;
this
.radComboBox2.DisplayMember = displayMember;
this
.radComboBox2.ValueMember = valueMember;
this
.radComboBox2.DataSource = subView;
}
private
DataTable CreateTable()
{
DataTable result =
new
DataTable();
result.Columns.Add(
new
DataColumn(
"Name"
,
typeof
(
string
)));
result.Columns.Add(
new
DataColumn(
"Value"
,
typeof
(
int
)));
for
(
int
i = 0; i < 70; ++i)
{
DataRow row = result.NewRow();
row[
"Name"
] = i.ToString();
row[
"Value"
] = i;
result.Rows.Add(row);
}
return
result;
}
private
void
radComboBox1_SelectedIndexChanged(
object
sender, EventArgs e)
{
int
value = (
int
)
this
.radComboBox1.SelectedValue;
// Compose filter expression based on the selected value in the first combo box.
// This is a rather silly filter but it serves the example. You can provide whaterver filter you need
// provided it has the correct syntax. Look up the RowFilter property of DataView in the MSDN for details
// on the syntax.
string
filter =
"Value = "
+ value.ToString();
this
.subView.RowFilter = filter;
}
}
Please write again if you need further assistance.
Sincerely yours,
Victor
the Telerik team