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;
                    }
                }

 

posted @ 2018-12-22 11:52  enych  阅读(14964)  评论(4编辑  收藏  举报