This nearly drove me crazy.  I’ve been working with the Developer’s Express grid in Windows Presentation Framework (WPF), and have NEVER been able to find a way to center the data in the column.  Turns out, it’s rather easy, BUT, it requires using the control nesting that makes WPF powerful and frustrating.

To center the text in the column, the dxg:GridColumn needs to have an EditSettings tag added.  Inside of that tag, add an TextEditSettings tag and set the HorizontalContentAlignment to “Center”.  Voila!

Example:

<dxg:GridControl Name=”gcTest”>
<dxg:GridControl.Columns>
<dxg:GridColumn Name=”GridColumn1″ FieldName=”TEST_ID” Header=”ID” Width=”100″ HorizontalHeaderContentAlignment=”Center” VisibleIndex=”0″>
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings HorizontalContentAlignment=”Center” />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Name=”GridColumn2″ FieldName=”DESCRIPTION” Header=”Description” Width=”100″ HorizontalHeaderContentAlignment=”Center” VisibleIndex=”1″>
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings HorizontalContentAlignment=”Center” />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
</dxg:GridControl.Columns>
</dxg:GridControl>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s