Controls - Do you use a ToolTip to show the full text of hidden ListView data?
Last updated by Brady Stroud [SSW] 8 months ago.See historyWhen you can't see all the text for an item in a ListView you need to expose the full text via a ToolTip.
The code to do this is:
private ListViewItem hoveredItem;
private void listView1_MouseMove(object sender, MouseEventArgs e) {
ListView lv = (ListView) sender;
ListViewItem item = lv.GetItemAt(e.X, e.Y);
int columnIndex = 1;
if (item != hoveredItem) {
hoveredItem = item;
if (item == null) {
toolTip1.SetToolTip(lv, "");
} else {
// Make sure the mouse hovered row has the subitem
if (item.SubItems.Count > columnIndex) {
toolTip1.SetToolTip(lv, item.SubItems[columnIndex].Text);
} else {
toolTip1.SetToolTip(lv, "");
}
}
}
}