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 8187895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:43:06+00:00 2026-06-07T02:43:06+00:00

I have a combo box in my application that has 17 different options. In

  • 0

I have a combo box in my application that has 17 different options. In my code, I have an if statement for all 17 of these options.

int colorchoice = colorSelect.SelectedIndex;
if (colorchoice == 0)
{
textBox1.AppendText("the color is black");
}
if (colorchoice == 1)
{
textBox1.AppendText("the color is dark blue");
}
and so on...

I have been able to print what is selected in the combo box, i.e. Black or Dark Blue, however, I need what is printed to have no spaces or caps.

if (colorchoice == 0)
{
textBox1.AppendText("the color is " + colorSelect.SelectedText);
}

So the result should be black or darkblue. How could I do this without changing the caps and spaces in my combo box so it still looks nice but will print out what I need.

My idea was to assign a string to each of the 17 options, but I have not been able to figure out how to do this.

Any help is appreciated. Thanks!

  • 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-07T02:43:08+00:00Added an answer on June 7, 2026 at 2:43 am

    Q1 however, I need what is printed to have no spaces or caps.

    Ans1

    textBox1.AppendText("the color is " 
            + colorSelect.SelectedText.ToLower().Replace(" ", ""));
    

    Q2: How could I do this without changing the caps and spaces in my combo box so it still looks nice but will print out what I need?

    Ans 2: The above code will not have any effect on your combobox.

    Q3: My idea was to assign a string to each of the 17 options, but I have not been able to figure out how to do this.

    Ans3: Why don’t you create an array of your items like

    string[] myarray = new string[]{ "Black", "Dark Blue" , ....};
    

    Then use it as

    textBox1.AppendText("the color is " + 
         myarr[colorSelect.SelectedIndex].ToLower().Replace(" ", ""));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a combo box in a C# Windows form application that is being
I have a combo box ( comboBox1 ) in my application that lists catagories
in my swing application I have a combo box with an ItemListener that does
I have a combo box on an MVC3 application. When a new item is
I'm using multiple threads in my application. Basically I have a combo box and
I have an application that has a combobox that varies in length depending on
I have written a WPF Line of Business application that has a particular sections
I have implemented a combo box which has a check box in it (Windows
I am writing windows from application in that i am using combo box control.
I have a combobox in a view that receives information about application state changes,

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.