Ever wanted to create a DataGridView for WinForms that allowed you to rotate
the angle of the column header text?
CustomDataGrid grid = new CustomDataGrid();
grid.Font = new System.Drawing.Font("Microsoft Sans Serif",
12f,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point,
((byte)(0)));
grid.Dock = DockStyle.Fill;
grid.ColumnHeadersHeight = 60;
grid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
new System.Windows.Forms.DataGridViewTextBoxColumn(),
new System.Windows.Forms.DataGridViewTextBoxColumn()
});
grid.Columns[0].MinimumWidth = 100;
grid.Columns[0].HeaderText = "Name";
grid.Columns[1].MinimumWidth = 100;
grid.Columns[1].HeaderText = "Age";
grid.Rows.Add(new object[] { "Steve", 19 });
grid.Rows.Add(new object[] { "Doug", 22 });
grid.RotationAngle = 90;
this.Controls.Add(grid);
My friend Tim sent me a class file that inherits from DataGridView and implements a RotationAngle property and simply overrides the OnCellPainting method.
The code is
here if you are interested.