LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically getting a .NET PictureBox label

Solved!
Go to solution

Hey folks, hope you're well.

 

Having difficulty getting the label string of a .NET PictureBox (System.Windows.Forms.PictureBox) inside of LabVIEW.

Has anyone successfully managed this before? Would appreciate a couple of pointers!

0 Kudos
Message 1 of 6
(1,880 Views)

Not exactly sure what you're asking.

 

Did you add a .NET container to the front panel, load the PictureBox control in it, and now want to read the label?

 

If so, you should be able to just right-click and create a property node for the terminal and read the label text just like any other LabVIEW terminal:

Kyle97330_0-1666634390538.png

 

Message 2 of 6
(1,846 Views)

Thanks for the response, that's definitely a good way of doing it with connected property nodes.
My apologies for not specifying with more detail - I'd like to be able to pass the reference from a picture box to a property node further down, in order to read the corresponding LabVIEW label.

 

lima_97_0-1666684754879.png

 

When I try and do this, the property node "switches" target class, and no longer has the property. I'm assuming I could typecast to a more specfic class, but I'm not having much luck trying to do that. Any thoughts?

0 Kudos
Message 3 of 6
(1,818 Views)
Solution
Accepted by topic author lima_97

It seems you can not get the refnum of the .net container from the PictureBox.

But the can get container refnum from VI Server.

Untitled.pngUntitled.jpg

 

George Zou
Message 4 of 6
(1,792 Views)

@lima_97 wrote:

I'd like to be able to pass the reference from a picture box to a property node further down, in order to read the corresponding LabVIEW label.

 

lima_97_0-1666684754879.png

 

When I try and do this, the property node "switches" target class, and no longer has the property. I'm assuming I could typecast to a more specfic class, but I'm not having much luck trying to do that. Any thoughts?


 

In your code, you're using the .NET reference returned by the terminal, which gives you access to the properties of the inserted control.

 

What you actually want is a reference to the container, which you can get in the way zou showed, or more easily by right clicking the control or the terminal and selecting Create>>Reference.


___________________
Try to take over the world!
Message 5 of 6
(1,757 Views)

Thankyou both for your response, the method of accessing the text property via VI server worked great!

Attached below is what I ended up doing:

 

lima_97_0-1666771455393.png

 

 

I get the inserted object inside the container, cast it to a .NET object type, then typecast that to the specific class.

0 Kudos
Message 6 of 6
(1,741 Views)