From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Drawing controls on user supplied Graphics value instead of default windows form

I would like to dynamically create an LED control, and draw it on another user control that I created.
 
I use the LED.Draw() method, using my Graphics value.
 
The LED draws, but does not respond to any further value changes.
 
I cannot use Controls.Add(), because the LED will appear at the wrong location.
 
Is there a way to change the "internal" Graphics value, and be able to use Controls.Add()?
 
Thanks.
0 Kudos
Message 1 of 5
(3,311 Views)
When you use the Draw method, it is like taking a snapshot of the LED at that point in time. Any changes you make to the actual LED control after you have called Draw will not be reflected in the drawn LED. To allow me to suggest a suitable work around, I am curious to know what kind of application you are developing? I am eager to find out why using Controls.Add on the form is not suitable? If the location of the LED is a problem, then what problem does changing the Location property present that is unsuitable for your application? Basically, I am trying to find out the motivation for using an image of the control rather than the control itself.

Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 2 of 5
(3,302 Views)

Abhishek,

Obviously from your reply, this is a mistake that I am making.

I do wish to use the control, but it will not display on my custom user control.

The area of the form that I would like the LED gets "overdrawn" by my user control.

This causes the LED control to be hidden.

I would like to "place" the LED control on top of my user control.

Thanks for the information.

Dave Yancich

 

0 Kudos
Message 3 of 5
(3,266 Views)
I attached an example of a usercontrol that does some custom painting with LED on it. It seems to behave ok.

Give it a go. It's a VS2003 project i made with Mstudio 8.0.1
Bilal Durrani
NI
Message 4 of 5
(3,253 Views)
Bilal,
 
Thank you for the reply...Sorry I did not reply sooner...Have not had a chance to review the posts.
 
The sample code is EXACTLY what I was looking to do!
 
Thanks again,
Dave Yancich
0 Kudos
Message 5 of 5
(3,193 Views)