// ctor public DataGridCalc() { // create calc engine _ce = new DataGridCalcEngine(this); // row headers must be wider to show the row number this.RowHeadersWidth = 50; // center-align row and column headers this.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; // define the format to use for showing calculated numbers _styleNumber = new DataGridViewCellStyle(this.DefaultCellStyle); _styleNumber.Format = FORMAT_NUMBER; _styleNumber.Alignment = DataGridViewContentAlignment.MiddleRight; _styleDate = new DataGridViewCellStyle(this.DefaultCellStyle); _styleDate.Format = FORMAT_DATE; // make grid lines more subtle this.GridColor = Color.FromArgb(0xf0, 0xf0, 0xf0); }