private void button1_Click(object sender, System.EventArgs e) { // Resize the height of the column headers. EmployeeAvailabilitySubmissionGridview.AutoResizeColumnHeadersHeight(); // Resize all the row heights to fit the contents of all non-header cells. EmployeeAvailabilitySubmissionGridview.AutoResizeRows( DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders); }
private void dataGridView1_MouseDown(object sender, MouseEventArgs e) { // If the user right-clicks a cell, store it for use by the shortcut menu. if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hit = EmployeeAvailabilitySubmissionGridview.HitTest(e.X, e.Y); if (hit.Type == DataGridViewHitTestType.Cell) { clickedCell = EmployeeAvailabilitySubmissionGridview.Rows[hit.RowIndex].Cells[hit.ColumnIndex]; } } }