StrataFrame Forum

ThemedLinkMenu in inherited form

http://forum.strataframe.net/Topic25320.aspx

By Alex Bibiano González - 12/3/2009

Excuse me for the lot of questions I'm asking in the last days, but I'm just starting learn SF Crying

I have just created a base form with a ThemedLinkMenu. Now I have inherited some forms and want to add diferent ThemedLinkMenuItem's, but the item's collection is readonly in the derived forms. I have already changed the ThemedLinkMenu modifier to protected, but it's still readonly.

What I'm missing?

Lot of thanks for your time.

Alex B.

By Les Pinter - 12/3/2009

Hi Alex,

   I hope I understood you correctly. I created a form named MainForm, then added a ThemedLinkMenu. I then set its Modifiers property (under Design properties) to Public. Finally, I add another form that inherits from MainForm, and I'm able to add to its ItemCollection, and to respond to the Click event of the ItemCollection and identify which item was clicked. Does that come anywhere near the issue you describe?

Les

By Alex Bibiano González - 12/3/2009

Yes you are right, but there's still a problem.

When you add a item to the collection on the base form. If there's an ActionLinkMenuItem to the the itemcollection from the ActionLinkeMenu at the base form, you get a read-only ItemCollection in the inherited form.

By Alex Bibiano González - 12/4/2009

I have found a solution, but I'm not sure if it's the best. Comments are wilkome Smile

I have creates LinkMenuItem class and collection like in the Strataflix sample.

I have published the collection through a public property of the base form, so I can add new LinkMenuItems to the collection in the inherited forms.

On the Form.Load event of the base class, I add all the LinkMenuItems from the collection to the ThemedLinkMenu:

themedLinkMenu1.BeginUpdate();

themedLinkMenu1.ItemCollection.Clear();

foreach (ActionLinkMenuItem almi in ActionItems)

{

themedLinkMenu1.ItemCollection.Add(almi);

}

themedLinkMenu1.EndUpdate();

Thanks,

Alex B.

By Les Pinter - 12/4/2009

Hi Alex,

   I see what you mean; the problem is that the ThemedLinkMenu is marked Read-Only when inherited if the Collection contains any items. That's probably by design, although you can get around it by adding the initial selections in code in the base form's constructor:

    { InitializeComponent();
      ThemedLinkMenuItem themedLinkMenuItem1 = new ThemedLinkMenuItem();
      themedLinkMenuItem1.Key = "Exit";
      themedLinkMenuItem1.Title = "Exit";
      themedLinkMenu1.ItemCollection.Add( themedLinkMenuItem1 );

But your event handler in the forms that derive from it need to handle the default ("Exit" in this case). I also noticed that removing a ThemedLinkMenuItem in the base form's Items Collection doesn't visually clear it from the ThemedLinkMenu. I'm sure Trent has thoughts on the matter.

Les