The grid does support having more than one ColumnManagerRow in its headers, however it does not support (directly) having grouped column headers as demonstrated in the image below:
In order to simulate column grouping you must create a custom row (that derives from the Row class and not from the ColumnManagerRow class) and use it in your grid.
Demonstration
The following code (class) demonstrates the minimum implementation required to simulate column grouping:
VB.NET
Copy Code
Imports System Imports Xceed.Grid Imports System.Drawing
Public Class CustomColumnManagerRow Inherits Row
Protected Sub New( ByVal template As CustomColumnManagerRow ) MyBase.New( template ) End Sub
Public Sub New( ByVal selector As RowSelector ) MyBase.New( selector ) End Sub
Public Sub New( ByVal columns As Integer ) MyBase.New() m_columns = columns End Sub
Protected Overrides Function CreateInstance() As Xceed.Grid.Row Return New CustomColumnManagerRow( Me ) End Sub
Protected Overrides Sub PaintForeground( ByVal e As GridPaintEventArgs ) Dim width As Integer = 0 Dim lastColumn As Integer = 0
Dim j As Integer
For j = 0 To Me.ParentGrid.Columns.Count \ m_columns - 1
Dim i As Integer For i = 0 To m_columns - 1 width += Me.ParentGrid.Columns( lastColumn ).Width lastColumn = lastColumn + 1 Next i
e.Graphics.DrawLine( Me.ParentGrid.GridLinePen, e.DisplayRectangle.X + width - 1, _ 0, e.DisplayRectangle.X + width - 1, Me.Height ) Next j End Sub
Protected Overrides ReadOnly Property DefaultHeight As Integer Get Return 16 End Get End Property
Protected Overrides Function GetFittedDisplayHeight( ByVal mode As AutoHeightMode, ByVal graphics As Graphics, ByVal printing As Boolean ) As Integer Return Me.DefaultHeight End Function
Protected Overrides Readonly Property DefaultCanBeCurrent As Boolean Get Return False End Get End Property
Public Overrides ReadOnly Property IsBackColorAmbient As Boolean Get Return False End Get End Property
Protected Overrides ReadOnly Property DefaultBackColor As System.Drawing.Color Get Return SystemColors.Control End Get End Property
Private m_columns As Integer = 0 End Class
C#
Copy Code
using System; using Xceed.Grid; using System.Drawing; namespace Xceed.Grid { public class CustomColumnManagerRow : Row { protected CustomColumnManagerRow( CustomColumnManagerRow template ) :base( template ){}
public CustomColumnManagerRow( RowSelector selector ) :base( selector ){}
public CustomColumnManagerRow( int columns ) :base() { m_columns = columns; }
protected override Xceed.Grid.Row CreateInstance() { return new CustomColumnManagerRow( this ); }
protected override void PaintForeground( GridPaintEventArgs e ) { int width = 0; int lastColumn = 0;
for( int j = 0; j < this.ParentGrid.Columns.Count / m_columns; j++ ) { for( int i = 0; i < m_columns; i++ ) { width += this.ParentGrid.Columns[ lastColumn ].Width; lastColumn++; }