这是不是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 根据条件截取字符串,然后将每次截取的放入arraylist的每一项中。 C#做好的程序如何使用快捷键打开 关于.net,使用者需要理解到什么程度才够? 关于用C#实现web网页信息提取的问题 C#无边框窗体在WINDOWS任务栏中无法显示右键菜单 c#中通过SQL-DMO来备份、还原SQL Server2000 winform 的datagrid 里面怎样设模板列? 如何屏蔽comboBox上按下F4键显示下拉列表功能 数据库连接时的权限问题 希望大家帮个忙 .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();
}