Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the PropertyEditor control in a ContextMenuStrip

I'm interested in using the PropertyEditor control in a context menu grip but haven't been able to find an example of it being used in this fashion. Was wondering if anyone had any success or if it was even possible?

This would be useful as it would enable the user to change for example the plot colour / axis range / axis mode / etc of a graph through a context menu that is associated with that chart.
0 Kudos
Message 1 of 9
(5,260 Views)

Howdy Adamhb,

Measurement Studio 8.1 just released which included a new awesome feature just like the one you are describing. We introduced the Instrument Control Strip Control which can be used to display a set of Measurement Studio property edtior controls through the ToolStripPropertyEditor. This new feature in only available for use with Measurement Studio support for Visual Studio 2005. 

You can find a demo of this new feature on here. If you have Measurement Studio 8.1 for Visual Studio 2005, you can find an example of this feature in the <MeasurementStudioVS2005>\DotNET\Examples\UI\WindowsForms\InstrumentControlStrip directory. 

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 2 of 9
(5,246 Views)

Hi adamhb,

I just noticed that you also posted some questions regarding the instrument control strip control so I assume you already know about this feature. As far as being able to insert a PropertyEditor control into a ContextMenuStrip control, my initial thoughts are that this is not possible but I am not absolutely sure. I need to check into this and see what options are available with the ContextMenuStrip. 

If it turns out that this is not possible, I would definitely submit a product suggestion on this. 

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 3 of 9
(5,242 Views)

Hi adamhb,

I just tested out the ability to add a PropertyEditor control to the ContextMenuStrip control and it is possible. However, you must use the ToolStripPropertyEditor class since the ContextMenuStrip is looking for ToolStripItem objects.  For example, you could say

ToolStripPropertyEditor

mylinecolor = new ToolStripPropertyEditor();

mylinecolor.Source = new PropertyEditorSource(sampleWaveformPlot, "LineColor");

contextMenuStrip1.Items.Add(mylinecolor);

I used this text code in the Instrument Control Strip Features example mentioned earlier.

Best Regards,

Jonathan N.
National Instruments
Message 4 of 9
(5,237 Views)
Thanks for that, works a treat
0 Kudos
Message 5 of 9
(5,228 Views)
Additionally, do you know if it's possible to add a label that appears next to the ToolStripPropertyEditor control. In your example, I would like to place the text "Line Colour:" to the left of the property editor control. I can be it above the control by inserting a new ToolStripLabel control but arent sure how to place it alongside the control.
0 Kudos
Message 6 of 9
(5,226 Views)

Hi adamhb,

 

I googled and looked into the Visual Studio documentation and couldn't find any properties for the ContextMenuStrip control that allows you to have multiple ToolStripItem objects on one line. It appears that this might be a limitation of the ContextMenuStrip control, but perhaps I missed some property. I did notice the ToolStrip control as well as our Instrument Control Strip Control puts all the objects on one line. You can notice this behavior if you look at the Features shipping example mentioned earlier. The toolstrip across the top contains a bunch of items (so many that it has a drop down menu at the end). If you look at the drop menu at edit time, you notice the items are all on different lines. However at run-time, some of the items are side by side.  See attached screenshots "Design Time.jpg" and "Run Time.jpg".

 

You might want to do some further research into seeing if multiple ToolStripItem objects on one line in a ContextMenuStrip control is available. I would look at the Visual Studio documentation as well as do some further googling.

 

Best Regards,

Jonathan N.
National Instruments
Download All
Message 7 of 9
(5,212 Views)

You might be interested in knowing that we are working to make it easy to use PropertyEditor controls in the ContextMenuStrip and other ToolStrip derived controls easier at design-time for a future release of Measurement Studio.

Regarding placing a label control next to the ToolStripPropertyEditor, it can be done but the effort involved is not trivial. In order to accomplish this, you will need to implement your own layout engine for the ContextMenuStrip. In the .NET Framework, Microsoft has chosen to make implementations of the LayoutEngine (used to layout the items in the ContextMenuStrip) internal. The ContextMenuStrip uses an instance of the internal FlowLayout class that uses the maximum width of all the items to determine the width of the ContextMenuStrip. As the FlowLayout class is internal, you are going to have to completely re-implement its logic while adding yours to the mix. You will then need to derive a class from ContextMenuStrip and override the LayoutEngine property to return an instance of your layout engine.

The next best option I see is to use the MenuItem control in the ContextMenuStrip. MenuItem allows you to provide nested menus in the context menu. You can set the Text property of the MenuItem to "Line Color" and add the PropertyEditor to the DropDownItems collection of the MenuItem instead.

Message Edited by Abhishek Ghuwalewala on 12-19-2006 11:42 AM

Abhishek Ghuwalewala | Measurement Studio | National Instruments
Message 8 of 9
(5,204 Views)
Sounds terrific, thanks for the info. Is there an estimated release date for the future version accessible via a public roadmap or do we just need to wait eagerly? 😉

In regards to implementing my own layout engine, I think I'll make do for the time being, a bit over my head!!

the other option proposed is also a good interim solution, but i will just go with having the label followed by the PropertyEditor control vertically.

I appreciate the responses, thanks

Adam
0 Kudos
Message 9 of 9
(5,193 Views)