private void button_Click(object sender, EventArgs e) { string x = listView1.SelectedItems[0].SubItems[1].Text.ToString(); //选中行的第一列的值 string y = listView1.SelectedItems[0].SubItems[2].Text.ToString(); //选中行的第二列的值 string z = listView1.SelectedItems[0].SubItems[3].Text.ToString(); //选中行的第三列的值 Form s = new newsdetail(x, name); s.Show(); }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (this.listView1.SelectedItems.Count > 0 && sign_in_state == 1) { string x = listView1.SelectedItems[0].SubItems[1].Text.ToString(); //选中行的第一列的值 string y = listView1.SelectedItems[0].SubItems[2].Text.ToString(); //选中行的第二列的值 string z = listView1.SelectedItems[0].SubItems[3].Text.ToString(); //选中行的第三列的值 Form s = new newsdetail(x, name); s.Show(); } if (this.listView1.SelectedItems.Count > 0 && sign_in_state != 1) { string x = listView1.SelectedItems[0].SubItems[1].Text.ToString(); //选中行的第一列的值 string y = listView1.SelectedItems[0].SubItems[2].Text.ToString(); //选中行的第二列的值 string z = listView1.SelectedItems[0].SubItems[3].Text.ToString(); //选中行的第三列的值 MessageBox.Show(z); } }