首页 新闻 会员 周边 捐助

datagrid 有关问题

0
悬赏园豆:5 [已解决问题] 解决于 2008-10-24 19:42

大家看下我的第五行没记录

groupbox1.text显示5of 5,咋整的啊

代码: private SqlDataAdapter da;
        private DataSet dsScore;
        int cur;
        private void Frm5_6_Load(object sender, EventArgs e)
        {
            con.conDataBase();
            string sql = "select * from score";
            SqlCommand sqlCommand = new SqlCommand(sql ,con.coon );
            da = new SqlDataAdapter(sql, con.coon);
           // dt = new DataTable();
            dsScore=new DataSet() ;
           // dt = new DataTable();
           // da.Fill(dt);
         
            da.Fill(dsScore,"score");
            SqlCommandBuilder builder = new SqlCommandBuilder(da);
            this.BindingContext[dsScore, "score"].PositionChanged += new EventHandler(BingingManagerBase_PositionChanged );
            textBox1.DataBindings.Add(new Binding("Text", dsScore, "score.studID"));
           // dataGridView1.DataSource = dt;
            dataGridView1.DataSource = dsScore;
            dataGridView1.DataMember = "score";
           


        }
        private void ShowPosition()
        {
            int iCnt, iPos;
            iCnt = this.BindingContext[dsScore, "score"].Count;
            iPos = this.BindingContext[dsScore, "score"].Position + 1;
            if (iCnt == 0)
            {
                groupBox1.Text = "jgj";
            }
            else
            {
                groupBox1.Text = iPos.ToString() + "of" + iCnt.ToString();
            }
       
       
        }

        private void BingingManagerBase_PositionChanged(object sender, EventArgs e)
        {
            ShowPosition();
        }

大哥们给说下谢谢啊

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

阿乐的主页 阿乐 | 初学一级 | 园豆:105
提问于:2008-10-23 20:25
< >
分享
最佳答案
0

将winform的datagridview控件的AllowUserToAddRows 属性设置为false

老烟枪 | 初学一级 |园豆:15 | 2008-10-24 08:40
其他回答(1)
0

同意楼上

RicoRui | 园豆:3663 (老鸟四级) | 2008-10-24 17:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册