组合框和组框 [英] Combobox and groupbox

查看:93
本文介绍了组合框和组框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我有一个包含项目{item1,item2,item3 ...}的组合框
这些项目中的每一项都应使用不同的参数填充组框{textbox1,textbox2,textbox3}.
我的想法是创建一个不同的类{classitem1 classitem2},在其中声明用于用参数填充groupbox的所有方法,但作为一个初学者,程序员不确定如何做到这一点.
任何帮助请

从评论复制
抱歉,这是Windows窗体.
我的问题是如何从类中引用文本框的值例如,如果我创建

Hi I have a combobox with items {item1,item2,item3...}
Each of these items should fill a groupbox{textbox1,textbox2,textbox3}with different parameters.
My idea is to create a different class {classitem1 classitem2} where to declare all the methods for filling the groupbox with parameters but being a beginner programmer not quite sure about how to do this.
any help please

Copied from Comment
Sorry this is Windows Forms.
The problem for me is how to refer to values of textboxes from the class For example if I create

class 1 
{ 
public void fillGroupBox() 
{ 
//how to refer to form1.txtbox? 
}

推荐答案



这对您有帮助




this will help you


<pre lang="cs">
public class MyClass
{

public DataSet GetList(string txt1,string txt2,string txt3)
{

              SqlConnection cs1 = new SqlConnection("Data Source=nemesisfc; Initial Catalog=FreezerTemps; Integrated Security=TRUE");
            SqlCommand cmd1 = new SqlCommand();
            cs1.Open();
            cmd1.CommandText = "write ur sql select query here";
            DataSet dtst = new DataSet();
            SqlDataAdapter dp = new SqlDataAdapter(cmd1);
            dp.Fill(dtst);// for select query

            cs1.Close();
return dtst;
}


}




//-以您的形式




//---in your form

public void BindDrops()
{
    MyClass cl= new MyClass();
    combobox.DataSource = DTL.GetList(txtbx1.Text,txt2.Text,txt3.Text));
    combobox.DataBind();
}


public class MyClass
{


    /* For Load Data, Return as a Dataset */
    public DataSet FillData(Pass_your_Values)
    {
// COde for fillup.
    }
.......
.....



然后,您可以将这些数据集或可命项目绑定到组合框中.



And you can bind these dataset or daatable item into combobox.


这篇关于组合框和组框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆