private static void CustomFormatItem(ListBoxFormatItemEventArgs e, ListBox listBox) { if(e.Value == null) return; StringBuilder sb = new StringBuilder(); string s = e.Value.ToString(); bool hovered = listBox.IsItemHovered(e.ItemIndex); if(listBox.IsItemSelected(e.ItemIndex)) { sb.AppendFormat("--> {0} <--", s); } else { sb.Append(s.Replace(' ', hovered ? '-' : '_')); } e.Value = sb.ToString(); }
private static void CustomFormatItem(ListBoxFormatItemEventArgs e, ListBox listBox) { if (e.Value == null) { return; } StringBuilder sb = new StringBuilder(); string s = e.Value.ToString(); bool hovered = listBox.IsItemHovered(e.ItemIndex); if (listBox.IsItemSelected(e.ItemIndex)) { sb.AppendFormat("--> {0} <--", s); } else { sb.Append(s.Replace(' ', hovered ? '-' : '_')); } e.Value = sb.ToString(); }
private void DemoListBox_FormatItem(object sender, ListBoxFormatItemEventArgs e) { CustomFormatItem(e, DemoListBox); }
private void DemoCheckedListBox_FormatItem(object sender, ListBoxFormatItemEventArgs e) { CustomFormatItem(e, DemoCheckedListBox); }