把项目名选出来放到DataTable后,
循环DataTable,一个一个地插到comboBox
如:
comboBox1.Items.Add(”项目名“);
即可

解决方案 »

  1.   

    把项目名选出来放到DataTable后
    foreach(DataRow dr in dt)
    {
      radioButton rb=new radioButton();
      rb.Text=项目名;
      Form1.Controls.Add(rb);
    }
    可以实现你的问题二
      

  2.   

    小生愚昧,请教一下怎样把项目名放进DataTable?
      

  3.   

    项目名放进DataTable 就是把数据读到 dataset 或 reader 中 比如
    ddataset = new DataSet();
    dadapter.Fill(ddataset,"dtable");
    这样你的项目名就在 dtable 中了
      

  4.   

    radioButton 这个类是怎么来的?
    怎么定义它,或是引用什么命名空间?
      

  5.   

    System.Web.UI.WebControls 我只找到他属于这个类,但是我是在做WinForms程序呀。怎么搞?
      

  6.   


    你在winform下面
    根本就不用管它属于哪个命名空间
    因为默认已经添加了该命名空间
      

  7.   

    但是我不能实例化radioButton呀,就不能在Form上add呀。他会报:“ 找不到类型或命名空间名称“radioButton”(是否缺少 using 指令或程序集引用?)“的错误。请教
      

  8.   

    晕了
    没有仔细看
    shi-----------RadioButton
      

  9.   

    System.Windows.Forms命名空间下面
      

  10.   

    private void PopXiangMuMing_Load(object sender, System.EventArgs e)
    {
    sqlConnection1.Open();
    sqlCommand1.CommandText = "Select 维修项目名 from JJGZ_XiangMu";
    SqlDataReader dReader = sqlCommand1.ExecuteReader(); 
    while (dReader.Read())   
    {
    RadioButton rb=new RadioButton();
    rb.Text=dReader["维修项目名"].ToString();
    this.Controls.Add(rb);
    }
    dReader.Close();
    }
    我搞定这个了,但是只能添加一个控件,再看看。
      

  11.   

    晕,我在RadioButton rb=new RadioButton();
    rb.Text=dReader["维修项目名"].ToString();
    this.Controls.Add(rb);
    //的后面加了这句
    MessageBox.Show(rb.Text);
    //发现每个"维修项目名“都可以显示。窗体上只能显示一个,被覆盖了?还是定义rb的问题?
      

  12.   

    覆盖,生成控件所在位置问题!//加上int xyz=0;
    rb.Location= new System.Drawing.Point(xyz+=60, 0);//在循环体内,搞定!
      

  13.   

    当然是覆盖了呀!
    RadioButton rb=new RadioButton();
    rb.Text=dReader["维修项目名"].ToString();
    this.Controls.Add(rb);
    控件的名字都是一样的呀!!你可以加一个count的控制一下不可以嘛??
      

  14.   

    int x=0;
    int y=0;
    int count;rb.Name = "radioBox"+count++;
    rb.Location= new System.Drawing.Point(x,y);
    this.Controls.Add(rb);
    MessageBox.Show(rb.Name);

    x+=160;  //160为各个RadioButton的列间距 
    if(x>1000)     //一行显示完后换下一行 
    y+=100;   
    x=x%1000;   //这个1000大概可以定下来在窗体上一行上显示几个
    y=y%2000;
      

  15.   

    怎样确定选择了哪项呀?
    while(count)
    {
          if(radioBox