SoFunction
Updated on 2025-04-06

C# Use Winform to get the selected value of the drop-down box

I won't say much nonsense, let's just read the code~

string PrintName = ();
 PrintName = (); //
 if ( != 0)
 {
 }
 string PrintName = "";
 PrintName = (); //"Gprinter GP-1124T0"
 var ss0 = ; //Gprinter GP-1124T0"
 var ss = (); // 0
//Loop drop-down box  string ptr = (1); //Query the printer name in the system table  for (int i = 0; i < ; i++)
  {
    if ([i].ToString() == ptr)
    {
  = i;
 break;
    }
  }

Supplement: C# wpf gets the selected value of combobox

Get the currently displayed value

;

Get the selected value after SelectionChanged

;

The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.