private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { //var targetCell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex]; //if (targetCell.ReadOnly) return; if (ClickedCell(e.ColumnIndex, e.RowIndex, "StopTimer")) { var item = GetJobItemByRowIndex(e.RowIndex); var viewItem = ViewItems.FirstOrDefault(x => x.JobItemId == item.JobItemId); var timing = item.GetActiveTiming(); timing.Stop(); JobListViewItem.FillViewFromJobItem(viewItem, item); dataGridView1.InvalidateRow(e.RowIndex); jobItemBindingSource.ResetItem(e.RowIndex); ShowCelll(dataGridView1, e.RowIndex, "StartTimer"); HideCell(dataGridView1, e.RowIndex, "StopTimer"); } else if (ClickedCell(e.ColumnIndex, e.RowIndex, "StartTimer")) { var item = GetJobItemByRowIndex(e.RowIndex); var viewItem = ViewItems.FirstOrDefault(x => x.JobItemId == item.JobItemId); item.CreateNewTiming(); JobListViewItem.FillViewFromJobItem(viewItem, item); jobItemBindingSource.ResetItem(e.RowIndex); dataGridView1.InvalidateRow(e.RowIndex); ShowCelll(dataGridView1, e.RowIndex, "StopTimer"); HideCell(dataGridView1, e.RowIndex, "StartTimer"); } }
private void UpdateViewItemsFromJobItems() { //SuspendLayout(); //jobItemBindingSource.RaiseListChangedEvents = true; //jobItemBindingSource.Filter = ""; var count = 0; foreach (var viewItem in ViewItems) { var item = Items.FirstOrDefault(x => x.JobItemId == viewItem.JobItemId); if (item != null) { viewItem.ElapsedTime = item.GetActiveEllapsedTime().RemoveMilliSeconds().ToString(); JobListViewItem.FillViewFromJobItem(viewItem, item); if (viewItem.TimingIsActive) { try { jobItemBindingSource.ResetItem(count); } catch (Exception e) { // ignored } } } count++; //if (count > jobItemBindingSource.Count) break; } //jobItemBindingSource.SuspendBinding(); //jobItemBindingSource.RaiseListChangedEvents = false; //jobItemBindingSource.Filter = "1=0"; //ResumeLayout(); }