点击ListView 获取所选择行的数据

鼠标单击或者双击listView 行,或者相关的行数据

 

if (lvUserInfo.SelectedIndices != null && lvUserInfo.SelectedIndices.Count > 0)
            {
                ListView.SelectedIndexCollection indexCollection = lvUserInfo.SelectedIndices;
                txtUserID.Text = lvUserInfo.Items[indexCollection[0]].Text;
                txtUserName.Text = lvUserInfo.Items[indexCollection[0]].SubItems[0].Text;
                txtHomePhone.Text = lvUserInfo.Items[indexCollection[0]].SubItems[1].Text;
                txtCardID.Text = lvUserInfo.Items[indexCollection[0]].SubItems[2].Text;
                txtPhone.Text = lvUserInfo.Items[indexCollection[0]].SubItems[3].Text;

            }

 

posted @ 2020-04-04 09:56  逯文杰  阅读(1602)  评论(0编辑  收藏  举报