C#控件之ListView
1.设置属性View为Details
2.添加表头
this.listView1.Columns.Add("head1", 50); this.listView1.Columns.Add("head2", 50);
3.添加一行
listView1.Items.Add(new ListViewItem(new string[] {str1, str2 }));
4.鼠标悬停在listview
某项时弹出toolTip
提示
private void listView1_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e) { ToolTip toolTip = new ToolTip(); string itemInfor = "列名1:" + e.Item.SubItems[0].Text + "\n" + "列名2:" + e.Item.SubItems[1].Text + "\n" + "列名3:" + e.Item.SubItems[2].Text + "\n"; toolTip.SetToolTip((e.Item).ListView, itemInfor); }