Ticket T276551
Visible to All Users

How to add a title or a heading bar to a grid, above all column headers?

created 10 years ago

Hi I need to add a title for the grid, like customer details, above the column headers. How to add a title or a heading bar to a grid, above all column headers?

Please can you give me a solution?

Thanks,
Rohini

Answers approved by DevExpress Support

created 10 years ago

Hi Rohini,

You can accomplish this task by using the Banded Layout feature. Below is a code snippet illustrating how to use Bands in the GridControl.

XAML
<dxg:GridControl ItemsSource="{Binding}"> <dxg:GridControl.Bands> <dxg:GridControlBand Header="Customer Details"> <dxg:GridColumn FieldName="Name" /> <dxg:GridColumn FieldName="Address" /> </dxg:GridControlBand> </dxg:GridControl.Bands> <dxg:GridControl.View> <dxg:TableView /> </dxg:GridControl.View> </dxg:GridControl>

Please try this solution and let me know whether or not it meets your requirements.

Thanks,
Michael

    Show previous comments (3)

      Thanks, this works. Just one small thing though: how can I set the font for "Customer Details" band header to bold?

        Also, how to merge rows of the name column header? In the example you gave it is Name header is showing in two rows, can we make it look a little better by merging the rows and centering it?

        DevExpress Support Team 10 years ago

          Hi Rohini,
          Our DXGrid control doesn't support mixing band and column headers within one row. This means that the required layout cannot be created. The only way to do this is to "emulate" bands using additional columns. For example:

          XAML
          <dxg:GridControl.Bands> <dxg:GridControlBand> <dxg:GridColumn FieldName="Name" HorizontalHeaderContentAlignment="Center" /> </dxg:GridControlBand> <dxg:GridControlBand> <dxg:GridColumn Header="Address" HorizontalHeaderContentAlignment="Center" /> <dxg:GridColumn FieldName="Current" HorizontalHeaderContentAlignment="Center" dxg:BandBase.GridRow="1"/> <dxg:GridColumn FieldName="New" HorizontalHeaderContentAlignment="Center" dxg:BandBase.GridRow="1"/> </dxg:GridControlBand> </dxg:GridControl.Bands>

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.