private void OutputList_Initialize() { // owner draw for listbox so we can add color OutputList.DrawMode = DrawMode.OwnerDrawFixed; OutputList.DrawItem += new DrawItemEventHandler(OutputList_DrawItem); OutputList.ClearSelected(); // build the outputList context menu popUpMenu = new ContextMenu(); popUpMenu.MenuItems.Add(new MenuItem("Delete selected", OutputList_DeleteSelected, Shortcut.CtrlX)); popUpMenu.MenuItems.Add(new MenuItem("Clear All", OutputList_ClearAll)); popUpMenu.MenuItems.Add(new MenuItem("Select &All", OutputList_SelectAll, Shortcut.CtrlA)); popUpMenu.MenuItems.Add(new MenuItem("&Copy", OutputList_Copy, Shortcut.CtrlC)); popUpMenu.MenuItems.Add(new MenuItem("Copy All", OutputList_CopyAll)); popUpMenu.MenuItems.Add(new MenuItem("Unselect", OutputList_ClearSelected)); popUpMenu.MenuItems.Add(new MenuItem("Toggle Scrolling", OutputList_ToggleScrolling)); // despite the following the first item in the menu show up as "Clear All Ctrl+X" popUpMenu.MenuItems[0].ShowShortcut = false; OutputList.ContextMenu = popUpMenu; }
private void OutputList_ClearSelected(object sender, EventArgs e) { OutputList.ClearSelected(); OutputList.SelectedItem = -1; }