我有四个textbox框,如果在textbox1当中输入编号后,在textbox2,textbox3,textbox4里面会弹出对应的相关内容..请教大家方法,如果能有代码示例更好.谢谢!

解决方案 »

  1.   

                    dt = fairy.GetSql("select type,unit,price,number,saveid from saveinfo where savename='" + id+ "'");
                    textBox1.Text = id;
                    textBox2.Text = dt.Rows[0].ItemArray[0].ToString();
                    textBox3.Text = dt.Rows[0].ItemArray[1].ToString();
                    textBox4.Text = dt.Rows[0].ItemArray[2].ToString();
      

  2.   

    可以自己写个控件
    可以把textBox和panel一些控件组合起来,我只能提示下
    不知道能不能帮上你
      

  3.   


    private void textBox1_TextChanged(object sender, EventArgs e)
    {
      dt = fairy.GetSql("select type,unit,price,number,saveid from saveinfo where savename='" +      id+ "'");
                    textBox1.Text = id;
                    textBox2.Text = dt.Rows[0].ItemArray[0].ToString();
                    textBox3.Text = dt.Rows[0].ItemArray[1].ToString();
                    textBox4.Text = dt.Rows[0].ItemArray[2].ToString();
            }
      

  4.   


    private   void   textBox1_TextChanged(object   sender,   EventArgs   e) 

        dt   =   fairy.GetSql("select   type,unit,price,number,saveid   from   saveinfo   where      savename='"+id+   "'"); 
         textBox1.Text   =   id; 
         textBox2.Text   =   dt.Rows[0].ItemArray[0].ToString(); 
         textBox3.Text   =   dt.Rows[0].ItemArray[1].ToString(); 
         textBox4.Text   =   dt.Rows[0].ItemArray[2].ToString(); 
     }
      

  5.   

    不知道楼主有没有其他的数据源,如果没有的话只单纯的实现你说的功能就简单了: private void textBox1_TextChanged(object sender, EventArgs e)
            {
                if (this.textBox1.Text!="")
                {
                    if (this.textBox1.Text == "1")
                    {
                        this.textBox2.Text = "11";
                        this.textBox3.Text = "111";
                        this.textBox4.Text = "1111";
                    }
                    else if (this.textBox1.Text == "2")
                    {
                        this.textBox2.Text = "22";
                        this.textBox3.Text = "222";
                        this.textBox4.Text = "2222";
                    }
                    else if (this.textBox1.Text == "3")
                    {
                        this.textBox2.Text = "33";
                        this.textBox3.Text = "333";
                        this.textBox4.Text = "3333";
                    }
                    else if (this.textBox1.Text == "4")
                    {
                        this.textBox2.Text = "44";
                        this.textBox3.Text = "444";
                        this.textBox4.Text = "4444";
                    } 
                }
            }如果有表之类的数据源的话,那个“走猪观花”的代码改下就ok了!
    楼主问题解决了给分啊,别整个“无满意回复结帖”让大家不爽!!!