public partial class select : Form
    {
        private BindingManagerBase Navigator;
        private DataSet ds;
        //private Container ct;
        public select()
        {
            InitializeComponent();
            Display();
            Navigator = this.BindingContext[ds, "user_info"];
           
        }        private void Display()
        {
            string str = "server=(local);database=feng;uid=sa;password=";
            SqlConnection cn = new SqlConnection(str);
            try
            {
                cn.Open();
                string dastr = "select count(*) from user_info ";
                SqlDataAdapter da = new SqlDataAdapter(dastr,cn);
                ds = new DataSet();
                da.Fill(ds, "user_info");
            }
            catch (SqlException se)
            {
                MessageBox.Show(se.Message, "error");
            }
            finally
            {
                cn.Close();
            }
            //this.textBox1.DataBindings.Add("Text",ds,"user_info.userid");
            //this.textBox2.DataBindings.Add("Text",ds,"user_info.username");
            //this.textBox3.DataBindings.Add("Text",ds,"user_info.userpswd");
        }
         //退出
        private void button6_Click(object sender, EventArgs e)
        {
            this.Close();
        }
           //第一条
        private void button1_Click(object sender, EventArgs e)
        {
            Navigator.Position = 0;
        }
         //上一条
        private void button3_Click(object sender, EventArgs e)
        {
            if (Navigator.Position == 0)
                Navigator.Position = Navigator.Count - 1;
            else
                Navigator.Position -= 1;
        }
         //下一条
        private void button2_Click(object sender, EventArgs e)
        {
            if (Navigator.Position == Navigator.Count - 1)
                Navigator.Position = 0;
            else
                Navigator.Position += 1;
        }
          //最后一条
        private void button4_Click(object sender, EventArgs e)
        {
            Navigator.Position = Navigator.Count - 1;
        }
上面的代码是查询数据的 ,为什么当点击按扭都没反应啊??
我已经将textBox与数据库绑定了.只能显示第一条的记录,
请高手明言指点

解决方案 »

  1.   

    一定是拷贝的代码.InitializeComponent(); 
    里面没有声明 按钮的单击事件
      

  2.   

    执行之后 调用 Navigator.EndCurrentEdit()  看看 也许 可能 兴许 有用
    @@ 
      

  3.   

    partial class   
    InitializeComponent() 不在这个部分类里的
      

  4.   

    回完上一条后仔细看了下.也没发现有 向textBox 绑定或填内容的代码啊...
      

  5.   

    this.textBox1.DataBindings.Add("Text",ds,"user_info.userid"); 
    this.textBox2.DataBindings.Add("Text",ds,"user_info.username"); 
    this.textBox3.DataBindings.Add("Text",ds,"user_info.userpswd"); 
    我刚学的 不知道这是不是绑定的代码?
    我在textBox的属性里设置的绑定;
    谁告诉我 绑定代码怎么写;
    我拷的自动生成的一部分,还有我写的Display(),和几个按钮的单击事件;