10-24-2022 10:30 AM
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!
Solved! Go to Solution.
10-24-2022 01:04 PM
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:
10-25-2022 03:00 AM
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.
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?
10-25-2022 10:26 AM
It seems you can not get the refnum of the .net container from the PictureBox.
But the can get container refnum from VI Server.
10-26-2022 12:29 AM - edited 10-26-2022 12:30 AM
@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.
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.
10-26-2022 03:04 AM
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:
I get the inserted object inside the container, cast it to a .NET object type, then typecast that to the specific class.