C# Winform 获得下拉框 选中的值
string PrintName = cmbPrinter.SelectedIndex.ToString(); PrintName = cmbPrinter.SelectedItem.ToString(); //
if (cmbPrinter.SelectedIndex != 0) { } string PrintName = ""; PrintName = cmbPrinter.SelectedItem.ToString(); //"Gprinter GP-1124T0" var ss0 = cmbPrinter.Text; //Gprinter GP-1124T0" var ss = cmbPrinter.SelectedIndex.ToString(); // 0
//循环下拉框 string ptr = dals.SelectContentByID(1); //查询系统表中 打印机名称 for (int i = 0; i < cmbPrinter.Items.Count; i++) { if (cmbPrinter.Items[i].ToString() == ptr) { cmbPrinter.SelectedIndex = i; break; } }