首页 > 学院 > 开发设计 > 正文

wpfcomboBox取值问题

2019-11-14 16:43:20
字体:
来源:转载
供稿:网友

这是获取值后台代码    

PRivate void button1_Click(object sender, RoutedEventArgs e)
        {
            combBox = this.comboBox1.SelectedItem as ComboBoxItem;
            combBox1 = this.comboBox2.SelectedItem as ComboBoxItem;
            string type = combBox.Content.ToString();
            string type1 = combBox1.Content.ToString();
            MessageBox.Show(type+type1);
        }
        ComboBoxItem combBox;
        ComboBoxItem combBox1;
        string value = "";
        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem cbItem = (ComboBoxItem)(sender as ComboBox).SelectedItem;
            value = cbItem.Content.ToString();
            MessageBox.Show(value);

          // string v = (sender as ComboBox).SelectedValue.ToString();
           // string bx=  v as string;
           // MessageBox.Show(bx);
       
        }


上一篇:更新Literacy

下一篇:ping操作

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表