private void logtypeMenuItemClickHandler(object sender, EventArgs e) { ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender; EventLog logs = GetLogs.GetEventLogs(clickedItem.Name, listBox1.Text); LogViewer logviewer = new LogViewer(logs); // Take some action based on the data in clickedItem }
private void BuildLogItems() { List <Logs> logList = GetLogs.GetLogNames(listBox1.Text); ToolStripMenuItem[] logtypes = new ToolStripMenuItem[logList.Count]; for (int i = 0; i < logtypes.Length; i++) { logtypes[i] = new ToolStripMenuItem(); logtypes[i].Name = logList[i].LogName; logtypes[i].Tag = "specialDataHere"; logtypes[i].Text = logtypes[i].Name; logtypes[i].Click += new EventHandler(logtypeMenuItemClickHandler); } remoteLogsToolStripMenuItem.DropDownItems.AddRange(logtypes); }
public static List <Logs> GetLogNames(string computername) { List <Logs> logs = new List <Logs>(); GetLogs LogNames = new GetLogs(); EventLog[] remoteEventLogs; remoteEventLogs = EventLog.GetEventLogs(computername); Logs log = new Logs(); foreach (EventLog e in remoteEventLogs) { log = new Logs(); log.LogName = e.LogDisplayName; logs.Add(log); } return(logs); }