LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use .NET propertyGrid control in LabView

I would like to use the .NET PropertyGrid control in my LabView (8.5) application. To populate this control, I need a .NET Object and the PropertyGrid displays the property of this object. The problem is how to create a .NET object from LabView? For example, I would like to convert a cluster of data or a LabView object into a .NET Object to display the data in the PropertyGrid.
Thanks for your help.
 
Pierre Cottin
Researcher
INO
0 Kudos
Message 1 of 11
(5,357 Views)
Have you tried the To .NET Object function?
0 Kudos
Message 2 of 11
(5,333 Views)

Yes but this vi is limited to the conversion of string, path, number, arrays. The .Net object required to populate this control is more sophisticated: it has members (name and value to display) and attributes to control how information is organized (section names,...).

Pierre Cottin

0 Kudos
Message 3 of 11
(5,326 Views)
You probably want to start with a .NET Constructor for your .NET object data type and use its properties and methods to fill in its data. Then, once it's populated correctly, feed its reference into the propertyGrid control.





Message Edited by Jarrod S. on 07-29-2008 04:46 PM
Jarrod S.
National Instruments
0 Kudos
Message 4 of 11
(5,318 Views)
Why not just use the constructor for your class?
0 Kudos
Message 5 of 11
(5,288 Views)

Thanks Jarrod for your suggestion. Unfortunately, if I link the Hashtable object to the PropertyGrid, it displays the proterties of the HashTable object like Count (with the value 3 if, for example, I have 3 sets of keys and values), isReadOnly or Item. Key and value appear as Collection. Data is present in the grid but is not displayed as expected.

To answer smercurio_fc, I can use System.Object constructor but then this object has no method to add items or properties

0 Kudos
Message 6 of 11
(5,285 Views)
Personally I'm not at all familiar with the Hash Table or propertyGrid .NET classes, so I really don't know what to expect from their interaction. My only point was to demonstrate that you want to use a .NET constructor of the appropriate class to create a .NET data type. .NET only knows how to marshal basic LabVIEW data types such as integers and strings. It wouldn't know what to do with a LabVIEW cluster or class. You'll have to create a .NET data object (of your desired type) and use its properties and methods to populate it. After that, hope it works well the propertyGrid control.
Jarrod S.
National Instruments
0 Kudos
Message 7 of 11
(5,281 Views)
OK... Let's back up a second. If I understand you correctly you want to display the properties for a cluster using the .NET PropertyGrid control. I don't really know what that means, but let's skip that for now. A PropertyGrid control requires that you attach a .NET class to it so that the public properties of the .NET class are available to the control. A LabVIEW cluster has no direct .NET class counterpart.

You would need to create a .NET class to represent your cluster and attach it to the PropertyGrid. I'm assuming you don't want to do this because if you change your cluster, then you need to change your .NET class.

It sounds like you're trying to create properties for a .NET class at run-time. In essence, you start with a base System.Object, and add properties to it. Frankly, I don't think this is possible, even with the System.Reflection namespace, or using the PropertyDescriptors, but I'm not a .NET guru.

This leads me to ask a different question: What are you trying to accomplish with the PropertyGrid control in relation to your cluster? A cluster is a datatype. It's not a class. So, what properties are you trying to access/change?
0 Kudos
Message 8 of 11
(5,275 Views)
smercurio,
Your description is pretty accurate. As I do not want to create a .NET class specific to the set of property/value I want to display, as you mentioned, I need to create this class at runtime. And it seems to me quite a complicated (even impossible) task.
What I want to do at the end of the day is to display a list of pair parameter name / value in a PropertyGrid. This list could come from a file or a cluster of data and does not always have the same structure. Having a basic .NET object that can be populated by Labview at runtime would be the solution. I found yesterday someone doing that inside the .NET world (http://www.codeproject.com/KB/tabs/Dynamic_Propertygrid.aspx):it can add and remove items on the fly. I have to figure out now if it would be of some help in Labview.
0 Kudos
Message 9 of 11
(5,253 Views)
You would need to compile the "CustomClass" class into a .NET assembly, which is quite easy to do. Then you can use its constructor in LabVIEW to do something similar to the example shown there. The attached example is one possible implementation.
Message 10 of 11
(5,240 Views)