回复 楼主 q1318717
很简单吧
下面给一个简单的例子:
public void listViewBindNoGroup(string sql, ListView lv, int colounNum)
{
con.Open();
//获取组名
OdbcCommand cmd = new OdbcCommand(sql, con);
OdbcDataReader sdr = cmd.ExecuteReader();
lv.BeginUpdate();
while (sdr.Read())
{
ListViewItem lt = new ListViewItem();
lt.Text = sdr[colounNum].ToString();
lt.ImageIndex = 0;
lv.Items.Add(lt);
}
sdr.Close();
con.Close();
lv.EndUpdate();
}
private void listView1_Click(object sender, EventArgs e)
{
if (nodeName != parentNodeName)
{
int count = listView1.Items.Count;
if (count > 0)
{
Form3 fm3 = new Form3();
fm3.xm = listView1.SelectedItems[0].Text;//选中listview的值
fm3.zm = nodeName;
fm3.ShowDialog();
}
}
}
[此贴子已经被作者于2017-6-17 22:58编辑过]