Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
How to use a switch case statement in conjunction with a group box in c#?

I am new to C# and I am trying to check which one of seven radio button within a group box is checked. The line with the "case" is giving me trouble. I am able to make it work using multiple if statements, but I would like to know if a switch statement would work too. Thanks for your help! Here is the code snippet:

      {
          if (OptMaennlich.Checked == true)
          {
              double Grundumsatz = (double)NumGewicht.Value * 24;
              switch (GrpAktivitaet)
              {
                  case OptSchlafen.Checked == true
                      double PAL = 1.0;
                      break;

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If you are still stuck and you are using Windows Forms, I would suggest subscribing to the CheckedChanged event either in the properties inspector or in the code behind for each of the radio buttons you have in your groupbox. Switching on the Text Property of the RadioButton is one way of achieving this in the event.

In your initialisation code:

OptSchlafen.CheckedChanged += SomeFunctionToCheckChangedState;

and in your code a function:

private void SomeFunctionToCheckChangedState(object sender, EventArgs e)
{
    // Insert your check logic here
    switch((sender as RadioButton).Text)
    {
        case "radiobuttontext":
            //what you want to do goes here
        break;
    }
}

When you click the radio button this event will be fired and the function called.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda