public int Compare(object x, object y) { OutlookGridRow obj1 = (OutlookGridRow)x; OutlookGridRow obj2 = (OutlookGridRow)y; if (obj1.Cells[this.columnIndex].Value != null && obj2.Cells[this.columnIndex].Value != null) { if (obj1.Cells[this.columnIndex].ValueType == typeof(DateTime) && obj2.Cells[this.columnIndex].ValueType == typeof(DateTime) && obj1.Cells[this.columnIndex].Value != null && obj2.Cells[this.columnIndex].Value != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = DateTime.Now; if (DateTime.TryParse(obj1.Cells[this.columnIndex].Value.ToString(), out dt1) && DateTime.TryParse(obj2.Cells[this.columnIndex].Value.ToString(), out dt2)) { return(DateTime.Compare(dt1, dt2) * (direction == ListSortDirection.Ascending ? 1 : -1)); } else { return(0); } } else { return(string.Compare(obj1.Cells[this.columnIndex].Value.ToString(), obj2.Cells[this.columnIndex].Value.ToString()) * (direction == ListSortDirection.Ascending ? 1 : -1)); } } else { return(0); } }
public int Compare(object x, object y) { OutlookGridRow obj1 = (OutlookGridRow)x; OutlookGridRow obj2 = (OutlookGridRow)y; return(string.Compare(obj1.Cells[this.columnIndex].Value.ToString(), obj2.Cells[this.columnIndex].Value.ToString()) * (direction == ListSortDirection.Ascending ? 1 : -1)); }
// the OnCellMouseDown is overriden so the control can check to see if the // user clicked the + or - sign of the group-row protected override void OnCellMouseDown(DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0) { return; } OutlookGridRow row = (OutlookGridRow)base.Rows[e.RowIndex]; if (row.IsGroupRow && row.IsIconHit(e)) { System.Diagnostics.Debug.WriteLine("OnCellMouseDown " + DateTime.Now.Ticks.ToString()); row.Group.Collapsed = !row.Group.Collapsed; //this is a workaround to make the grid re-calculate it's contents and backgroun bounds // so the background is updated correctly. // this will also invalidate the control, so it will redraw itself row.Visible = false; row.Visible = true; } else { base.OnCellMouseDown(e); } }
protected override void OnCellBeginEdit(DataGridViewCellCancelEventArgs e) { OutlookGridRow row = (OutlookGridRow)base.Rows[e.RowIndex]; if (row.IsGroupRow) e.Cancel = true; else base.OnCellBeginEdit(e); }
protected override void OnCellDoubleClick(DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { OutlookGridRow row = (OutlookGridRow)base.Rows[e.RowIndex]; if (row.IsGroupRow) { row.Group.Collapsed = !row.Group.Collapsed; //this is a workaround to make the grid re-calculate it's contents and backgroun bounds // so the background is updated correctly. // this will also invalidate the control, so it will redraw itself row.Visible = false; row.Visible = true; return; } } base.OnCellClick(e); }