How to add a 'light' to my .Net Form Application -> does the toolbox provide simple lights i.e. red/green

Greetings,

I have a .Net Form App and I want to add two lights which will signify a GO/NO-GO status.

After looking through all the options on the toolbox, I didn't see anything that seemed to fit the bill.

How can I incorporate such a thing and what is the exact code to turn such lights on with the appropriate color ?

Thanks
John500Asked:
Who is Participating?
 
SmithJWCommented:
You're on the right lines so far with the 2 picture boxes.
Assuming PictureBox 1 is 'green', and ValidInput is  a bool, set by a Validation function:

if ( ValidInput == true )
{
   PictureBox1.visible = true;
   PictureBox2.visible = false;
}
else
{
   PictureBox1.visible = false;
   PictureBox2.visible = true;
}


obviously replace ValidInput with whatever condition you want to check, but this will get you going for now.
0
 
OnegaZhangCommented:
There is a article talking about VB.NET. Wish it is helpful to you as well.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet08142002.asp
Creating Visual Basic .NET Controls from Scratch
0
 
mahesh1402Commented:
and also a LED control in C# here may help :http://www.codeguru.com/csharp/csharp/cs_controls/custom/article.php/c4793/

MAHESH
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
John500Author Commented:
Thanks to both of you, but this won't work for me.  I'm looking for direct references to Visual C++ .Net toolbox objects and some sample code C++ code
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Two icons - one red, one green.
Use two times picture control, one for each icon.
For go hide the red picture and show the green, you get the idea.
0
 
John500Author Commented:
AndyAinscow,

>> Two icons - one red, one green.

I'm not as versed in such things as you might expect.  How would I create an icon from scratch?  After that I'm guessing the properties of the icon would allow me to set a default color.  If so, I'd need to know how to change that color during run-time.  Lastly, I would prefer the icon to be round rather than square.  The more I think about it, I don't need two, just one that can change from red to green.

Thanks !
0
 
John500Author Commented:
AndyAinscow,

I guess I'm not as bad as I thought I was.  I created a round red icon and a green one also from 'Paint'.  I saved them as icons and then imported them into my project's GroupBox as pictureBoxes.  

What did you mean by 'two times picture control' ?  Are you saying I should put one picture on top of the other and then show which ever one I want depending upon the status?  In any event, these objects are called pictureBox1 and pictureBox2.  What would the code look like to display them ?

Thanks
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
In the resource editor of visual studio you can create icons.
Put a picture box control onto your form and you should be able to select the type of picture as icon and the ID (of the icon you just created).  Now you have one picture control with for instance a red circle in it.  Do the same to create a second, green, icon.  Add a second picture control and link the picture control to the icon.
Now all you need to do is toggle the visible state of the control depending on which icon you want to display.


You need two picture controls because each contains one image.  (You could do it with one control and swap the images but using two controls and visibility is simpler to code).
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.