首页 新闻 搜索 专区 学院

WINFOM疑问。。高手进

0
[已关闭问题] 关闭于 2012-12-22 22:05

 BindingSource mBindingSource;

DataTable dt = new DataTable();
            dt.Columns.Add("Name");
            dt.Columns.Add("Age");
            DataRow drTemp;
            drTemp = dt.NewRow();
            drTemp[0] = "Jordan";
            drTemp[1] = 10;
            dt.Rows.Add(drTemp);
            drTemp = dt.NewRow();
            drTemp[0] = "KOBE";
            drTemp[1] = 20;
            dt.Rows.Add(drTemp);
            dt.AcceptChanges();
            mBindingSource = new BindingSource();
            mBindingSource.DataSource = dt;
            this.dataGridView1.DataSource = mBindingSource;
            this.textBox1.DataBindings.Add("Text", mBindingSource, "Name",false,  DataSourceUpdateMode.OnPropertyChanged);
            this.textBox2.DataBindings.Add("Text", mBindingSource, "Age", false, DataSourceUpdateMode.OnPropertyChanged);

 

if (((DataTable)mBindingSource.DataSource).GetChanges() == null)
                {
                    MessageBox.Show("没有修改到数据!");
                }
                else
                {
                    DataRow dr = ((DataRowView)mBindingSource.Current).Row;
                    ((DataTable)mBindingSource.DataSource).AcceptChanges();
                }

为什么在datagrid单元格中修改就不会提示(("没有修改到数据!");)!!!而在textBox中修改会提示呢??不是做了DataBindings了吗!!!!????

彬彬@科比的主页 彬彬@科比 | 初学一级 | 园豆:43
提问于:2012-12-21 23:02
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册