C# listview之点击空白区仍然不失去选中项的状态
2010-02-05 13:33
369 查看
要做出这个效果,不能在mouseclick,click事件响应函数中写代码,因为大部分空白区不会响应该事件,mousedown也不可,应用mouseup事件来响应该要求,代码如下:
private void listView1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { WizardBase.IntermediateStep inter = (wizardControl1.WizardSteps[wizardControl1.CurrentStepIndex] as WizardBase.IntermediateStep); if (listView1.SelectedItems.Count > 0) { //if (ListViewTmpIndex != -1) //{ // listView1.Items[ListViewTmpIndex].Selected = false; //} //ListViewTmpIndex = listView1.Items[listView1.SelectedIndices[0]].Index; switch (listView1.Items[listView1.SelectedIndices[0]].Index) { case 0: //TODO:File if (inter != null) { inter.Subtitle = "打开一个或多个文件"; inter.Refresh(); } break; case 1: //TODO:Oracle if (inter != null) { inter.Subtitle = "连接一个OracleSpatial服务"; inter.Refresh(); } //wizardControl1. break; case 2: //TODO:PostgreSql if (inter != null) { inter.Subtitle = "连接一个PostGIS服务"; inter.Refresh(); } break; case 3: //TODO:ArcSDE if (inter != null) { inter.Subtitle = "连接一个Arc SDE服务"; inter.Refresh(); } break; case 4: //TODO:SQLServer if (inter != null) { inter.Subtitle = "连接一个SQLServer服务"; inter.Refresh(); } break; default: break; }//switch 选中的行 } else if (listView1.SelectedItems.Count <= 0)//点击空白区 { if (this.listView1.FocusedItem != null) { ListViewItem item = this.listView1.GetItemAt(e.X, e.Y); if (item == null) { this.listView1.FocusedItem.Selected = true; } } } }//left_button_up }//listView1_MouseUp
相关文章推荐
- [转]当鼠标点击ListView下面的空白区域时,如何使ListView的原item选项仍然为选中状态
- [转]当鼠标点击ListView下面的空白区域时,如何使ListView的原item选项仍然为选中状态
- [转]当鼠标点击ListView下面的空白区域时,如何使ListView的原item选项仍然为选中状态
- Winform,C#,listView判断鼠标点击是行还是listView的空白区
- Winform,C#,listView判断鼠标点击是行还是listView的空白区
- Winform,C#,listView判断鼠标点击是行还是listView的空白区
- c# listview 点击空白,也不改变焦点
- [转]C#如何在ListView失去焦点的情况下仍然保持Item高亮
- c#里listview里如何获取点击的是哪一列
- C# listview 点击列头排序
- C#:ListView控件如何实现点击列表头进行排序
- C#ListView失去焦点选中行不能高亮显示的问题解决
- ListView 按钮点击状态混乱之解决
- C#:ListView控件如何实现点击列表头进行排序?
- 如何记录Listview中item的点击状态
- C# Winfrom中Listview控件点击获取行
- android 监听软键盘弹起和关闭状态与点击空白区域软键盘隐藏
- 使用MediaPlayer为组件的各种状态播放声音效果(Button点击,Listview上下拉)
- Android ListView条目按钮点击状态混乱解决方案
- C#获取鼠标在listview右键点击单元格的内容方法