这是不是DataGridView的一个BUG? 本帖最后由 caozhy 于 2011-03-18 19:57:07 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 怎么说呢,代码修改的,有时候没有触发一个事件比如在网页自动化操作中,就有这个问题,需要fireEvent 不要动不动就怀疑 BUG。===============为了严谨,我已经用代码测试了,而且贴出源代码,因此“动不动就怀疑BUG”的结论不成立。另外,我写的C/S程序,SelectionChanged事件每次都产生了,只不过得到的是改变前的而已。 是挺奇怪的。没仔细研究。不过你要编程遍历数据的话,下面的方法更简便。 private void Form1_Load(object sender, EventArgs e) { DataTable tb = new DataTable(); tb.Columns.Add("title", typeof(string)); for (int i = 0; i < 50; i++) { DataRow row = tb.NewRow(); row[0] = i.ToString(); tb.Rows.Add(row); } BindingSource bs = new BindingSource(); bs.DataSource = tb; dataGridView1.DataSource = bs; } private void dataGridView1_SelectionChanged(object sender, EventArgs e) { label1.Text = dataGridView1.CurrentCell.RowIndex.ToString(); } private void btnNext_Click(object sender, EventArgs e) { BindingSource bs = (BindingSource)dataGridView1.DataSource; bs.MoveNext(); } .net 1.1的时候,用BindingManagerBase。http://blog.csdn.net/fangxinggood/archive/2008/04/18/2304047.aspx 请教关于Brush的问题 读xml字符串的问题 为什么鼠标在移动最后一个二级菜单上就消失不见了。 怎样获取System.Collections.IEnumerable里边有多少列? 创建窗口句柄时出错 关于会员管理软件和刷卡设备的接口 代码中的一个小问题 c#中如何实现VC中的return功能 请教个问题,为什么老是提示这个错误?? 求类似索爱musicDJ的源码 .net remoting 服务器广播 客户端在内网 的问题 SerialPort关闭卡死
比如在网页自动化操作中,就有这个问题,需要fireEvent
===============
为了严谨,我已经用代码测试了,而且贴出源代码,因此“动不动就怀疑BUG”的结论不成立。
另外,我写的C/S程序,SelectionChanged事件每次都产生了,只不过得到的是改变前的而已。
{
DataTable tb = new DataTable();
tb.Columns.Add("title", typeof(string));
for (int i = 0; i < 50; i++)
{
DataRow row = tb.NewRow();
row[0] = i.ToString();
tb.Rows.Add(row);
}
BindingSource bs = new BindingSource();
bs.DataSource = tb;
dataGridView1.DataSource = bs;
} private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
label1.Text = dataGridView1.CurrentCell.RowIndex.ToString();
} private void btnNext_Click(object sender, EventArgs e)
{
BindingSource bs = (BindingSource)dataGridView1.DataSource;
bs.MoveNext();
}