c# listview控件中如何在选中某一行时将此行的第3列数据提取到文本框中显示
展开全部
现在设计里双击listview,就会产生 listView1_SelectedIndexChanged(object sender, EventArgs e)的函数,函数应该如下写:(根据你的listView的名称更改下面listView1)
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedIndices != null && listView1.SelectedIndices.Count > 0)
{
ListView.SelectedIndexCollection c = listView1.SelectedIndices;
textBox1.Text = listView1.Items[c[0]].SubItems[2].Text;
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedIndices != null && listView1.SelectedIndices.Count > 0)
{
ListView.SelectedIndexCollection c = listView1.SelectedIndices;
textBox1.Text = listView1.Items[c[0]].SubItems[2].Text;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询