DataGridView Column autosize mode not working?

DataGridView Column autosize mode not working?

Post by Grant Sche » Thu, 08 Oct 2009 06:47:15


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 =

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

Grant Schenck

DataGridView Column autosize mode not working?

Post by Bob Barrow » Thu, 08 Oct 2009 07:34:45

***canned wrong-newsgroup reply************************
There was no way for you to know it (except maybe by browsing through some
of the previous questions in this newsgroup before posting yours - always a
recommended practice) , but this is a classic (COM-based) ADO newsgroup.
ADO.Net bears very little resemblance to classic ADO so, while you may be
lucky enough to find a dotnet-knowledgeable person here who can answer your
question, you can eliminate the luck factor by posting your question to a
group where those dotnet-knowledgeable people hang out. I suggest

Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the