Adding a context menu to an ultraLabel

Posted by ChUIMonster on 05-Mar-2009 07:45

Today's dotNet programming puzzle

I have a bunch of ultraLabels on a screen. I'd like to add a context menu (right-click) to each one. The menu would have two options on it "option 1" and "option 2" and I would like it to indicate if they are selected or not with a check mark (similar to the way that "Windows Explorer -> View -> Toolbars" behaves).

I'm not a windows guy so I'm not 100% sure that I've described that right. So correct me or ask questions if that isn't clear.

I need to do this without using the Visual Designer. 1) I don't want to do it 50 times (there are 50+ labels on the screen) and 2) The program no longer loads in VD anyway

I see that the ultraLabel widget has a ContextMenu property and some likely looking events. But I'm not comfortable that I know enough about how they work to correctly code a solution.

It's ok if anyone wants to program it for me but I'm really just looking for some insight into how to approach the problem -- what controls need to be created and how they interact.

All Replies

Posted by Peter Judge on 05-Mar-2009 08:11

It's ok if anyone wants to program it for me but

I'm really just looking for some insight into how to

approach the problem -- what controls need to be

created and how they interact.

I usually create a dummy Form - ah, form1, the times we've had - and do stuff on it, and then inspect the contents of InitializeComponent.

You'll need an UltraToolbarsManager. In that component's context menu, select Customize (I believe). You can then add actions and create a context menu - IG calls it a Popup Menu, I think. The UltraLabel has a ContextMenu property that allows you to select/associate one of the context menus with the label.

hth

-- peter

Posted by ChUIMonster on 05-Mar-2009 08:19

Sometimes all you need to do is ask the question

I've got it working. The trickiest parts were figuring out that the "checked" attribute doesn't need to be somehow "enabled" and that the "click" event goes with the MenuItem not the ContextMenu (on reflection that's a "duh" moment).

What seemed like a daunting task actually turns out to have been relatively easy. Now I just have to make the jump from "option1" and "option2" to something a tad more useful

Thanks!

This thread is closed