DataGridView Column autosize mode not working?

G

Grant Schenck

Hello,

I'm having a problem with a DataGridView header.

I have a form with a DataGridView.

In code I add a column. I set the AutoSizeMode to
DataGridViewAutoSizeColumnMode.ColumnHeader as shown here

comboBoxColumn.DataSource = dtStationList;
comboBoxColumn.DisplayMember = "Name";
comboBoxColumn.ValueMember = "StationListID";
comboBoxColumn.DataPropertyName = "StationListID";
comboBoxColumn.HeaderText = "Station List Name";
comboBoxColumn.AutoSizeMode =
DataGridViewAutoSizeColumnMode.ColumnHeader;

I end up with a header that has "Station" on the first line and "List Name"
on the second line. If I use "StationListName" as the header text then the
header is shown on one line.

So, how do I prevent the DataGridControl from putting my header on multiple
lines?

Thanks!
 
G

Gregory A. Beamer

I end up with a header that has "Station" on the first line and "List
Name" on the second line. If I use "StationListName" as the header
text then the header is shown on one line.

So, how do I prevent the DataGridControl from putting my header on
multiple lines?

If you do not have enough space for the headers, it will wrap regardless
of mode.

Is this win forms or ASP.NET?

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
G

Grant Schenck

Winforms... Thanks!
--
Grant Schenck

Gregory A. Beamer said:
If you do not have enough space for the headers, it will wrap regardless
of mode.

Is this win forms or ASP.NET?

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 

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