The following code shows what I' am try todo: I want to initialize a popup menu with a couple of menu item programmatically. Some of them should be regrouped and the group should be separated by horizontal separator lines:
ultraToolbarsManager > ultraToolbar > popup >
menu item1
menu item2
--------------------------------
buttonToolGenerateHA
menu item3
menu item4
ultraToolbarsManager "ultraToolbarsManagerDP" contains a ultraToolbar "ultraToolbarDP" to which a popup menu "popupFunctions" containing the menu (buttontool) item "buttonToolGenerateHA" should be appended
before the menu item a separator line should be placed, why I set the IsFirstInGroup property to true.
I tried different combination, actually I can't set the property, either buttonToolGenerateHA.InstanceProps is null or setting the IsFirstInGroup property is ignored. The menu item are displayed without separator
Any idea to init the tools correctly programmatically?
----------------------------------
//>>> buttonToolGenerateHA.InstanceProps != null
ultraToolbarDP.NonInheritedTools.AddRange(new ToolBase[] { popupFunctions,});
ultraToolbarsManagerDP.Toolbars.AddRange(new UltraToolbar[] { ultraToolbarDP, });
//>>> attach Tools to the Toolbar manager
ultraToolbarsManagerDP.Tools.Add(buttonToolGenerateHA);
//>>> buttonToolGenerateHA.InstanceProps = null!
popupFunctions.Tools.Add(buttonToolGenerateHA);
??? when to set buttonToolGenerateHA.InstanceProps.IsFirstInGroup = true; ???
InstanceProps is null in this case because the tool you are accessing is a root tool. InstanceProps is only non-null on a tool that is on a toolbar or a menu or some other displayed instance. The InstanceProps apply to a tool that is in place on some kind of container.
So, if you have a tool on a toolbar, you would could do something like this:
ToolbarsManager.Toolbars["My Tooblar"].Tools["Publish Template"].InstanceProps.IsFirstInGroup = true;
But you have to get a tool on a toolbar, you can't use the root tool, because the root tool is essentially a template for that tool so that an instance of that tool can be created and placed somewhere.
Sorry to dredge up such an old topic but I'm running into the issue and I tried the VERIFIED ANSWER
...ToolbarsManager.Tools["Publish Template"].InstanceProps.IsFirstInGroup = true;
and InstanceProps there is also NULL.
I am attempting to programatically add to a UltraToolBarManager and PopUpMenuTool. Note: there were manual items added to the PopUpMenuTool when the control was originally setup. I can get the ButtonTool objects added to both the UltraToolBarManager and the PopUpMenuTool collections, however, none of the items display. Why would this be? Your assistance would be appreciated. Here is a code snippet:
Dim oButtonTool As Infragistics.Win.UltraWinToolbars.ButtonTool = Nothing
Dim oListOfToolButtons As List(Of Infragistics.Win.UltraWinToolbars.ButtonTool) = New List(Of Infragistics.Win.UltraWinToolbars.ButtonTool)
For i = 0 To oCurrentInvoice.Contracts.Count - 1 oButtonTool = New Infragistics.Win.UltraWinToolbars.ButtonTool("TransactionWorkbenchAllTo12" + oCurrentInvoice.Contracts.Item(i).ContractID) If i = 0 Then oButtonTool.InstanceProps.IsFirstInGroup = True End If oButtonTool.InstanceProps.Visible = DefaultableBoolean.True oButtonTool.SharedPropsInternal.Enabled = True oButtonTool.SharedProps.Visible = True oButtonTool.SharedPropsInternal.Caption = "Assign To " + oCurrentInvoice.Contracts.Item(i).ContractID oListOfToolButtons.Add(oButtonTool) utm.Tools.Add(oButtonTool) oToolTransactionWorkbenchAssign.Tools.AddTool("TransactionWorkbenchAllTo12" + oCurrentInvoice.Contracts.Item(i).ContractID) Next
Hi Chris,
thanks a lot. That's it. I wasted a couple of hours before to check out different combinations.
Best regards
Kagel
Hello,
Before I explain what is happening and how to resolve your issue, I suggest reviewing the "Root Tools and Instance Tools" section provided in our online help to familiarize yourself with these items.
When you add a tool (buttonToolGenerateHA) to the PopupMenuTool's Tools collection, you are adding the root tool. When it is added, it is cloned and an instance tool is inserted into the collection. As 'buttonToolGenerateHA' is still referring to the root tool, it does not have a InstanceProps available. To access the InstanceProps, you'll need to index (by index or key) into the Tools collection of the PopupMenuTool.
popupFunctions.Tools[buttonToolsGeneratedHA.Key].InstanceProps.IsFirstInGroup = true;
I hope this helps. Let me know if you need further assistance.
Thanks,
Chris