C# listView更新数据问题 我在listView更新数据时候 它的滚动条都会回到最上面 请问我想它原来在哪里就在哪里应该怎么做 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 设置listview的选择项listView1.Items[1].Selected = true; 更新前记下原来的索引值,更新后用listView1.Items[index].EnsureVisible(); this.listBox1.SetSelected(itemIndex, true); ListBox.SelectIndex=ListBox.Items.Count-1; 大概思路就是你更新前记录一下当前选中行的所有index,然后更新后在设置他的选中行为这行如:this.ListView1.Item[Index]=true; 首先在单击单元格时获得当前行的索引 int index;//当前行索引 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { index = this.dataGridView1.CurrentRow.Index; }然后在你刷新数据的方法中调用以下,就可实现定位 this.dataGridView1.DataSource = ds.Tables[0]; dataGridView1.Rows[index].Selected = true; this.dataGridView1.FirstDisplayedScrollingRowIndex = index; this.listBox1.SetSelected(itemIndex, true); ListBox.SelectIndex=ListBox.Items.Count-1; WCF服务启动后无法关机 如何实现限制用户使用WEB邮箱及文件的下载? 如何动态更改母版生成页页面的标题?????? 如何在dataGridView1里限制某一单元格输入的字符只能是数字或小数点呀。 请问如果将DataGridView中的数据[手工添加的]转为DataSet ASP.NET 2003 WEB 项目如何发布! C#怎么建水晶報表 win8 app store开发中在线程或定时器中访问页面的控件 一个编程习惯的问题 请教达人:C#抓包模拟网站登录问题 发个帖~!祝大家新年快乐 C#继承?
listView1.Items[1].Selected = true;
更新后用
listView1.Items[index].EnsureVisible();
ListBox.SelectIndex=ListBox.Items.Count-1;
如:this.ListView1.Item[Index]=true;
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
index = this.dataGridView1.CurrentRow.Index;
}
然后在你刷新数据的方法中调用以下,就可实现定位
this.dataGridView1.DataSource = ds.Tables[0];
dataGridView1.Rows[index].Selected = true;
this.dataGridView1.FirstDisplayedScrollingRowIndex = index;
ListBox.SelectIndex=ListBox.Items.Count-1;