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
325
Raising event for UltraComboEditors
posted

I have a UltraComboEditor in one of the ListView cell. My requirement is to load the second comboeditor based on the first Comboeditor value. How to do this.... ?

Thanks in advance.

  • 575
    posted

    If you need to filter one combo base off of the other in a grid, you can, but its not easy.

    The following steps will resolve the problem:
    (The control to be filtered will henceforth be referred to as UDD)

    1.  The UDD must be an UltraDropDown.  The dataSource, dataMember, valueMember, and displayMember should be set appropriately.  It is not necessary to use a dataview as the datasource, as the dataview's rowfilter will not be used. (e.g. you want all of the values to be available to the UDD).
    2.  The column using the UDD should have the ValueList property set to the UDD.  UltraDropDown does not implement the necessary interface to be used as an EditorControl.
    3.  The UDD used in my example only has a single band (found in UltraWinGridDesigner > Band and Column Settings > Band 0).  The use of multiple bands may require modifications to the method described here.
    4.  The filtering function consists of two lines of code at its heart:
     band.ColumnFilters(ColumnNameToFilterBy).ClearFilterConditions()
     band.ColumnFilters(ColumnNameToFilterBy).filterConditions.Add(FilterComparisonOperator.Something, comparisonValue)

    ColumnNameToFilterBy is the column in the UDD that you want to filter by.  ColumnFilters are not declared explicitly, so this is the only code necessary regarding the column filters.
    The first line clears all pre-existing filter conditions.  It is possible to have multiple filter conditions set up on a single column.
    The second line adds a new filter condition.  FilterComparisonOperator is an enum, and there are numerous consts within it. (e.g. equals, greater than, less than).  The comparison value is the value that the specified column will be compared to.
    5.  I found it necessary to call this code from three different events:  The UltraGrids BeforeEnterEditMode and InitializeRow and the first ComboBox's RowSelected events.  In the BeforeEnterEditMode, I found the key in the first ComboBox's cell and used it to call the filter function.  In the InitializeRow event, I cleared the filter, and in the the ComboBox's RowSelected event I used the value.
    6.  Some additional precautions will have to be taken:  If values in the UDD are selected before the comboBox value is specified, either the combobox selected value will have to be changed to reflect the UDD choice, or if the user selects a value from the ComboBox that would preclude the chosen value from being in the UDD, the UDD value will have to be unselected.
     
     
    After you have this setup you will capture the combo_valuechanged event with the selected value.  Base off of this you will need to set your columnfilter on your band.
     
    _band.ColumnFilters("ColumnName").FilterConditions.Add(FilterComparisionOperator.Equals, cbo.Value)
    To clear the filter, simply pass a 0 as the filter condition.
     
    We had this issue a while back and there was another good post about it, but unfortunetly it is now missing.  I think the post was moved when the new forum went up. 
     
     
     
    Hope this helps,
    Brandon