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
365
updating ToolBarsManager on a UserControl
posted

Hi all.  I'm curious, being new o this type of development, on how to have changes post back to a Form/Control designer.  I have read many articles on the subject but they seem to be tailored to what they are accomplishing but not generic enough to apply to other things.  So I have created a custom control, added a toolBarsManager, added a PopupMenuTool.

I have a property on the custom control that accepts an UltraGrid.

  [System.ComponentModel.Editor(typeof(CustomControls.UIDesigners.GridNavigatorGridEditor), typeof(System.Drawing.Design.UITypeEditor))]

    public UltraGrid UltraGrid
    {
      get
      {
        return _ultraGrid;
      }
     set
     {
        _ultraGrid = value;

        if (_ultraGrid != null)
        {
            if (Presenter == null)
                 Presenter = new GridNavigatorPresenter(this as GridNavigator);

            Presenter.FindFirstKeys = new List<string>();

            GridNavigatorFilterSelection filterCreation = new GridNavigatorFilterSelection();

            foreach (var col in _ultraGrid.DisplayLayout.Bands[0].Columns)
            {
                  Presenter.FindFirstKeys.Add(col.Key); //List<string>
            }

            ToolBase[] toolBase = new ToolBase[Presenter.FindFirstKeys.Count];

            int index = 0;

            foreach (string key in Presenter.FindFirstKeys)
            {
                 //this section uses the designer's method CreateTool that builds the PopupToolMenu item with default set of StateButtonTools
                 toolBase[index] = filterCreation.CreateTool(key, "String"); //by default, set all as strings
                 index++;
            }

            this.ToolBarManager.Tools.AddRange(toolBase); //have to add the tools to the ToolbarManager before adding them to the actual Tool

            PopupMenuTool filterMenuTool = tbmNavigator.Tools["FilterPopupMenu"] as PopupMenuTool;
            filterMenuTool.Tools.AddRange(toolBase);

            //update the ui
            PropertyDescriptorCollection properties;
            properties = TypeDescriptor.GetProperties(typeof(M3InfragisticsGridNavigator));

            //doesn’t update the ToolBarsManager
            PropertyDescriptor changedTS = properties.Find("ToolBar", false);
            changedTS.SetValue(navigator, navigator.ToolBarManager);

            //Does add the PopupMenuTools, but doesn't add them to the ToolbarsManager
           PropertyDescriptor changedPopup = properties.Find("FilterMenuTool", false);
           changedPopup.SetValue(navigator, filterMenuTool);

           //doesn’t add these (here is the StateButtonTools)
           PropertyDescriptor changedTools = properties.Find("FilterMenuTool.Tools", false);
           changedTools.SetValue(navigator, filterMenuTool.Tools);

        }

        OnPropertyChanged(nameof(UltraGrid));
    }

My end goal is to be able to edit the existing PopupMenuTool (FilterMenuTool), add some child PopupToolMenu(s) that have StateButtonTools. 

So, if anyone has done something like this where you created a CustomControl based on a 3rd party control and was able to access a collection that contains another collection and store that on the designer pls pls pls tell me (step by step would be nice).

Parents Reply Children
No Data