Topics: CAB & Smart Client Software Factory
Nov 21, 2007 at 5:58 AM
There is one menu called "Text - 1" in the main menu of Shell Layout.
I registered this menu as a UIExtensionSite.

WorkItem.UIExtensionSites.RegisterSite("UIText1", View.Text1)

I wanna change the text of this menu from other module.

WorkItem.UIExtensionSites.RegisterSite("UIText1").Text = "My New Text" ;

But there is no property like that.

So, How can I change the text of this menu?

Thanks in advance.

Nov 21, 2007 at 6:08 PM

When you access to an item using the UIExtensionSites collection of the WorkItem, you don´t have access to the object that you register in the collection. The UIExtensionSites collection uses the concept of UIElementAdapter. The UIElementAdapters are in charge of management an specific type of UIElement. All the UIElementAdaptersonly allows you to add an remove items from one type of UIElement.
The following code explains how to have access to an UIElement through its UIElementAdapter.

// Add a button to the main ToolBar.
ToolStripButton myButton = new ToolStripButton("myButton");
If what you want to do is to have access directly to the UIElement to modify its properties, I recommend to you use the Items collection of the RootWorkItem.

// Add a button to the Items collection of the RootWorkItem
ToolStripButton myButton = new ToolStripButton("MyButton");
RootWorkItem.Items.Add(button, "MyButton");
// In a Business Module
// Use the button added before
ToolStripButton b1 = (ToolStripButton)WorkItem.Items["MyButton"];
b1.Text = "MyNewText"; 
Please let me know if this helps.

Mariano Converti
Nov 22, 2007 at 2:57 AM
Thanks. It works..

How can I remove this button from other module??

Let's I have Module1 and Module2. I have added one toolstrip button in Module1 and I wanna remove one toolstrip from Module2. I was thinking to use "Remove(uiExtName)" but I was not able to register the UI element in Module1.

I tried the following code in Module1 but it doesn't work.

Dim tsApplicationMgmtMenu As New ToolStripMenuItem("Application Management")
tsApplicationMgmtMenu.Name = "tsUserGuide"
''AddHandler tsApplicationMgmtMenu.Click, AddressOf ApplicationMgmtToolStripMenuItem_Click
WorkItem.Commands(Constants.CommandNames.AppMgmtMenuCommandName).AddInvoker(tsApplicationMgmtMenu, "Click")

Dim mnuItem As New ToolStripDropDownButton

With mnuItem
.Text = text
End With

WorkItem.UIExtensionSites.RegisterSite("", mnuItem) '' <<< it doesn't work. :(

Nov 23, 2007 at 2:55 AM
I got it worked.

I have to register the UI after adding.


WorkItem.UIExtensionSites.RegisterSite("a", mnuItem) '' <<< it doesn't work. :(

Thanks anyways.