private void SetLastChangedTextbox(int nomineeDBId) { if (nomineeDBId > 0) { LogEntryArr logEntryArr = new LogEntryArr(); logEntryArr.Fill(); logEntryArr = logEntryArr.Filter(nomineeDBId, DateTime.MinValue, ""); LogEntry logEntry = logEntryArr.GetLogEntryWithMaxId(); textBox_Last_Change.Text = logEntry.DateTime.ToString(); toolTip_Last_Changed.SetToolTip(textBox_Last_Change, logEntry.Entry); } else { textBox_Last_Change.Text = ""; toolTip_Last_Changed.SetToolTip(textBox_Last_Change, null); } }
private void UpdateListView_Log(int nomineeDBId, DateTime from, DateTime to) { listView_Log.Clear(); listView_Log.Columns.Add("תאריך"); listView_Log.Columns.Add("שעה"); listView_Log.Columns.Add("שם מועמד"); listView_Log.Columns.Add("פעולה"); LogEntryArr logEntryArr = new LogEntryArr(); logEntryArr.Fill(); logEntryArr = logEntryArr.Filter((int)comboBox_Nominee.SelectedValue, from, to); ListViewItem listViewItem; LogEntry logEntry; for (int i = 0; i < logEntryArr.Count; i++) { logEntry = logEntryArr[i] as LogEntry; listViewItem = new ListViewItem(logEntry.DateTime.ToString("dd-MM-yyyy")); listViewItem.SubItems.Add(logEntry.DateTime.ToString("HH:mm:ss")); listViewItem.SubItems.Add(logEntry.Nominee.ToString()); listViewItem.SubItems.Add(logEntry.Entry); listView_Log.Items.Add(listViewItem); } //stop drawing the listview to prevent flickering. listView_Log.BeginUpdate(); int width; foreach (ColumnHeader item in listView_Log.Columns) { //set the width to match the headersize and save the width in the int item.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); width = item.Width; //reset the width to match the columncontent size item.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); //if the header size is bigger then the column size the return to the headersize. if (width > item.Width) { item.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); } //make the width bigger in abit. item.Width = (int)Math.Ceiling(item.Width * 1.5); } //redraw the listview listView_Log.EndUpdate(); Size size = new Size(SystemInformation.VerticalScrollBarWidth, SystemInformation.HorizontalScrollBarHeight * 2 /*somehow the same as the columnHeader hight- wifh is unavailable*/); for (int i = 0; i < listView_Log.Columns.Count; i++) { size.Width += listView_Log.Columns[i].Width + 1; } for (int i = 0; i < listView_Log.Items.Count; i++) { size.Height += listView_Log.Items[i].Bounds.Height + 1; } listView_Log.Size = size; }