时间:2021-03-07 10:29:59 | 栏目:.NET代码 | 点击:次
我就废话不多说了,大家还是直接看代码吧~
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; } }
补充:C# wpf 获取combobox选中的值
获取当前所显示的值
combobox.Text;
获取SelectionChanged后选中的值
combobox.SelectedItem;