Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
765
How to dynamically populate Ultracombo#2 based on value selected in Ultracombo#1?
posted
I have a main Windows form whose code-behind "fills" a data table called "Site".  It is filled based on the user's office.  This is working correctly.
BUT...I have a button that launches another form which contains 2 Ultracombo objects.  Ultracombo#1 provides a list of offices.  DataSource is "officebindingsource", DataTable = "Office", DisplayMember is "office_name" and ValueMember is "office_code".  Ultracombo#2 should provide a list of sites based on the selected office (in Ultracombo#1).  Ultracombo #2's DataSource is "sitebindingsource", DataTable = "Site", DisplayMember is "site_description" and ValueMember is "site_id".  In Ultracombo#2, I set the DataBindings/Value = "officebindingsource - office_code" (bindingsource for Ultracombo#1).  I have one method that checks when the value of Ultracombo#1 is changed:

private void comboOffice_ValueChanged(object sender, EventArgs e)
{
      //Check if Office in Ultracombo#1 was changed        
       if (comboOffice.Value != null)
        {
            string office = comboOffice.Value.ToString();
           //comboCurrLoc is the 2nd Ultracombo on the form, should only display sites based on the user's selected office
            comboCurrLoc.Rows.ColumnFilters.ClearAllFilters();
            comboCurrLoc.Rows.ColumnFilters[
"OFFICE_CODE"].FilterConditions.Add(FilterComparisionOperator.Equals, office);
            comboCurrLoc.Value =
null;
}

I feel that I'm close, but when I change the value of the office in Ultracombo#1, the second combobox is blank.  Is there something else I should be adding to make the 2nd Ultracombo display the correct values?

 

Parents Reply Children