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
100
UltraComboEditor - Can I Use a Custom Control for the DropDown?
posted

I'd like to use a ComboBox control that when the dropdown button is pressed will display my custom control instead of the standard ListBox control.

An example can be found in the Visual Studio Properties window when editing a form. The BackColor property is a ComboBox type of control; when the dropdown button is pressed it shows a tab control that allows you to pick a color.

Can I do this with one of the IG controls?

Thanks,
- Josh

Parents
  • 69832
    Verified Answer
    Offline posted

    Yes, you can do this, but not really with an UltraComboEditor. The WinEditor controls support EditorButtons, which allow you to add any number of buttons to the edit area. For example, you can add a DropDownEditorButton to the UltraTextEditor's ButtonsRight collection, and assign a reference to your custom control to the DropDownEditorButton's Control property.

    Example:

    using Infragistics.Win;
    using Infragistics.Win.UltraWinEditors;

    //  Create a DropDownEditorButton and hook the events of interest
    DropDownEditorButton button = new DropDownEditorButton();
    button.Click += new EditorButtonEventHandler(this.OnDropDownEditorButtonClick);
    button.BeforeDropDown += new BeforeEditorButtonDropDownEventHandler(this.OnDropDownEditorButtonBeforeDropDown);
    button.AfterCloseUp += new EditorButtonEventHandler(this.OnDropDownEditorButtonAfterCloseUp);
    button.Control = new MyControl();

        //  Add the DropDownEditorButton to the UltraTextEditor's ButtonsRight collection
        this.ultraTextEditor.ButtonsRight.Add( button );
    }

    private void OnDropDownEditorButtonAfterCloseUp(object sender, EditorButtonEventArgs e)
    {
        UltraTextEditor textEditor = sender as UltraTextEditor;
        DropDownEditorButton button = e.Button as DropDownEditorButton;
        // TODO: Set the UltraTextEditor's Text to the custom control's value
    }

    private void OnDropDownEditorButtonBeforeDropDown(object sender, BeforeEditorButtonDropDownEventArgs e)
    {
        UltraTextEditor textEditor = sender as UltraTextEditor;
        DropDownEditorButton button = e.Button as DropDownEditorButton;
        // TODO: Parse the UltraTextEditor's Text and set the custom control's value
    }

    private void OnDropDownEditorButtonClick( object sender, EditorButtonEventArgs e )
    {
        UltraTextEditor textEditor = sender as UltraTextEditor;
        DropDownEditorButton button = e.Button as DropDownEditorButton;
    }

Reply Children
No Data