Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8389987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:52:09+00:00 2026-06-09T18:52:09+00:00

On a Windows Form, I’m trying to use PictureBoxes as status icons. I have

  • 0

On a Windows Form, I’m trying to use PictureBoxes as status icons. I have 4 icons for Running, Stopped, StartPending and StopPending. I wasn’t sure how best to do this, so I decided to just stack them on each other and make only the one that’s valid visible. I came up with something like this.

switch (currentServiceStatus)
{
    case "Running":
        pb_startedTestService.Visible = true;
        pb_startingTestService.Visible = false;
        pb_stoppedTestService.Visible = false;
        pb_stoppingTestService.Visible = false;
        break;
    case "StartPending":
        pb_startedTestService.Visible = false;
        pb_startingTestService.Visible = true;
        pb_stoppedTestService.Visible = false;
        pb_stoppingTestService.Visible = false;
        break;
    case "Stopped":
        pb_startedTestService.Visible = false;
        pb_startingTestService.Visible = false;
        pb_stoppedTestService.Visible = true;
        pb_stoppingTestService.Visible = false;
        break;
    case "StopPending":
        pb_startedTestService.Visible = false;
        pb_startingTestService.Visible = false;
        pb_stoppedTestService.Visible = false;
        pb_stoppingTestService.Visible = true;
        break;
}

Which I’m okay with if it was just one service, but there are at least 7 services I’m going to be checking and think that’s a little much for a little icon next to the service name. Am I being obsessive? Is it not that big of a deal and won’t make my code as sloppy as I think it will? Is there an easier or better way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:52:10+00:00Added an answer on June 9, 2026 at 6:52 pm

    Why not use one PictureBox and in your switch statement simply change out which image is being displayed. IE: PictureBox1.Image = …

    And assuming you have the pictures loaded into your resources, here is the syntax for accessing them.

    PictureBox1.Image = global::(Namespace).Properties.Resources.(PictureName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Windows form application(.Net 3.5) I have a textbox and a button on the form.
So I have a Windows form with a few fields to accept data and
I have a windows form application. On the form there are three groupboxs. Each
I have a windows form app, and a class which is called Game. Let's
I have one windows form file that each time I open it in Visual
I have a windows form where in I open new threads for server communication.
While loading a Windows Form (C#), I'm trying to iterate through all controls. So
net windows form application. I have a combo box and a text box and
I have windows form. In the constructor server thread starts thServer = new Thread(ServerThread);
I have a simple windows form with a statusStrip in VS2010, and no matter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.