c# winform 获取listview 选中行某列的值
2016-04-05 13:52
351 查看
private void lvAccountList_SelectedIndexChanged(object sender, EventArgs e) { //在此处设断点,发现点击不同的Item后,此事件居然执行了2次 //第一次是取消当前Item选中状态,导致整个ListView的SelectedIndices变为0 //第二次才将新选中的Item设置为选中状态,SelectedIndices变为1 //如果不加listview.SelectedIndices.Count>0判断,将导致获取listview.Items[]索引超界的异常 if (listview.SelectedIndices != null && listview.SelectedIndices.Count>0) { ListView.SelectedIndexCollection c = listview.SelectedIndices; lblTitle.Text = listview.Items[c[0]].Text; } }
相关文章推荐
- C#使用SOAP获取webservice实例解析
- C# out和ref参数修饰符
- 对"使用Mono Runtime Bundle制作安装包让C#桌面应用程序脱离net framework"增加说明
- c# get set 说明
- mono嵌入式应用研究(三):注册内部函数
- 算法實例-C#-信箱排序-PigeonHoleSort
- C#获取单元格值(使用NPOI插件)
- c#处理基于Modbus协议的串口通讯程序
- C# Regex ignoring non-capturing group
- mono嵌入式应用研究(二):虚拟机的初始化
- c# log组件 log4net使用介绍
- C# 利用ICSharpCode.SharpZipLib实现在线压缩和解压缩
- leetcode 3 : Longest Substring Without Repeating Characters 最长无重复子串 (C# 语言版)
- C# The process cannot access the file because it is being used by another process
- 基于C# 生成Zip压缩包代码
- C# 操作INI配置文件
- C# Distinct使用,支持对象的相等比较
- vs2015中 c#如何 编译成低版本供xp使用
- C#16位MD5加密算法
- C#流(stream)