void refresh() { dataGridViewMain.Rows.Clear(); addEntriesToDataGridView("Login", 4624); addEntriesToDataGridView("Logoff", 4647); addEntriesToDataGridView("Lock", 4800); addEntriesToDataGridView("Unlock", 4801); dataGridViewMain.Sort(dataGridViewMain.Columns[1], ListSortDirection.Descending); } void addEntriesToDataGridView(string name, int id) { EventLog log = new EventLog("Security"); var entries = log.Entries.Cast<EventLogEntry>() .Where(x => x.InstanceId == id) .Select(x => new { x.TimeGenerated, }).ToList(); foreach (var evl in entries) { dataGridViewMain.Rows.Add(new object[] { name, evl.TimeGenerated }); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)