怎么在点击查询后让程序获取到这两个下拉列表中的选项

解决方案 »

  1.   

    用循环读取combobox.Items的所有元素就可以,
      

  2.   

    在点击按钮的事件代码中添加如下两行代码即可。
    public void btnQuery_Click(object sender,EventArgs e)
    {
          ...
           string s1 = this.DropDownList1.SelectedItem.Text.Trim();
           string s2 = this.DropDownList2.SelectedItem.Text.Trim();
           ...
    }
      

  3.   

    错误 1 “lettey.Form1”不包含“DropDownList1”的定义,并且找不到可接受类型为“lettey.Form1”的第一个参数的扩展方法“DropDownList1”(是否缺少 using 指令或程序集引用?)
    出现这个错误时怎么回事 缺少引用?
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace lettey
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void label1_Click(object sender, EventArgs e)
            {        }        private void Form1_Load(object sender, EventArgs e)
            {
                // TODO: 这行代码将数据加载到表“db1DataSet1.bind_number”中。您可以根据需要移动或移除它。
                this.bind_numberTableAdapter.Fill(this.db1DataSet1.bind_number);
                // TODO: 这行代码将数据加载到表“db1DataSet.bind_type”中。您可以根据需要移动或移除它。
                this.bind_typeTableAdapter.Fill(this.db1DataSet.bind_type);        }        private void button1_Click(object sender, EventArgs e)
            {
                string s1 = this.comboBox1.SelectedItem.Text.Trim();
                string s2 = this.comboBox2.SelectedItem.Text.Trim();
            }
        }
    }这是我的代码 问题如下
    错误 1 “object”不包含“Text”的定义,并且找不到可接受类型为“object”的第一个参数的扩展方法“Text”(是否缺少 using 指令或程序集引用?)
    谁能帮我看看 谢谢
      

  5.   

    WinForm的ComboBox啊,本来还以为是DropDownList呢
    private void button1_Click(object sender, EventArgs e)
    {
      string s1 = this.comboBox1.SelectedValue; // this.comboBox1.SelectedText;
      string s2 = this.comboBox2.SelectedValue; //this.comboBox2.SelectedText;
    }
      

  6.   

        string s1 = this.comboBox1.SelectedValue.ToString();
        string s2 = this.comboBox2.SelectedText.Trim();