DataGrid Formatting Question

B

Bruce Schechter

I have a DataGrid control that I populate by binding it to an ArrayList.
The ArrayList contains objects of a class I created with several public
properties exposed to populate the respective columns.



I have two questions regarding this DataGrid control:

1.) There is an automatically-generated column along the left-hand side of
the DataGrid which is apparently provided to enable row selection. It
contains a little triangle to mark the currently-selected row. How can I
control the width of that column? (I don't know if it is even called a
"column", but I don't know what else to call it.)

2.) I am doing all formatting programmatically by creating a
DataGridTableStyle then creating each column respectively via
DataGridTextBoxColumn objects, etc. Finally, this new TableStyle, ts, is
added via myDataGrid.TableStyles.Add(ts); Whereas I am able to set the
font for the Header in this scenario (ts.HeaderFont), I have not found a way
to set the font for normal rows? If I try to set the font via the
DataGrid.Font property (after the above DataGridTableStyle is set), my font
specification seems to be outright ignored. How should I do this?



Cheers, Bruce
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Bruce,
1.) There is an automatically-generated column along the left-hand side of
the DataGrid which is apparently provided to enable row selection. It
contains a little triangle to mark the currently-selected row. How can I
control the width of that column? (I don't know if it is even called a
"column", but I don't know what else to call it.)

This thing is called "row header". I believe there's a property to control
its width either on the DataGrid class itself or on the DataGridTableStyle
class and this property should be called something like "RowHeaderWidth".
2.) I am doing all formatting programmatically by creating a
DataGridTableStyle then creating each column respectively via
DataGridTextBoxColumn objects, etc. Finally, this new TableStyle, ts, is
added via myDataGrid.TableStyles.Add(ts); Whereas I am able to set the
font for the Header in this scenario (ts.HeaderFont), I have not found a way
to set the font for normal rows?

Does the DataGridTableStyle expose a Font property? If yes, use this one. If
no, hmm..., this sounds strange as I remember I had no problem with
customizing the grid content font.
 

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