Alignment of columns in datagrid

T

Tim Conner

It seems that all fields in a standard DataGrid default to align to the left,
including numbers.

I can't find the "columns" property of the grid, to change the behavior of the
particular columns.

Where do I change that ?


Regards,
 
N

Norman Yuan

DataGrid->TableStyle(s)->GridColumnStyle(s). DataGridColumnStyle defines
column showed in DataGrid and has a property "Alignment".
 
R

René Meinecke

hi,

maybe i´m wrong, but i think u have to create a DataGridTableStyle for that.
try something like this:

DataGridTableStyle tableStyle = new DataGridTableStyle();

tableStyle.MappingName = TableName;

DataGridTextBoxColumn aColumnTextColumn = new
DataGridTextBoxColumn_NoActiveCell();

aColumnTextColumn.Alignment = HorizontalAlignment.Center;

tableStyle.GridColumnStyles.Add(aColumnTextColumn);



this.TableStyles.Clear();

this.TableStyles.Add(tableStyle);


hope this helps.

peace René
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top