DataGridView Column autosize mode not working?

Discussion in 'Microsoft ADO .NET' started by Grant Schenck, Oct 7, 2009.

  1. 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!
    --
    Grant Schenck
     
    Grant Schenck, Oct 7, 2009
    #1
    1. Advertisements

  2. "Grant Schenck" <> wrote in
    news:#:

    > 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! |
    *******************************************
     
    Gregory A. Beamer, Oct 8, 2009
    #2
    1. Advertisements

  3. Winforms... Thanks!
    --
    Grant Schenck

    "Gregory A. Beamer" <> wrote in message
    news:Xns9C9E58FA9B143gbworld@207.46.248.16...
    > "Grant Schenck" <> wrote in
    > news:#:
    >
    >> 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! |
    > *******************************************
     
    Grant Schenck, Oct 8, 2009
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sebastian Pusz

    Unbound column in DataGridView (.NET 2.0)

    Sebastian Pusz, Sep 16, 2004, in forum: Microsoft ADO .NET
    Replies:
    0
    Views:
    321
    Sebastian Pusz
    Sep 16, 2004
  2. MichaelB
    Replies:
    0
    Views:
    521
    MichaelB
    Oct 8, 2004
  3. Guest

    How do I change a Datagridview column type?

    Guest, Jan 7, 2006, in forum: Microsoft ADO .NET
    Replies:
    1
    Views:
    1,024
    Cor Ligthert [MVP]
    Jan 7, 2006
  4. Earl

    Datagridview image column nulls

    Earl, Nov 19, 2006, in forum: Microsoft ADO .NET
    Replies:
    2
    Views:
    3,099
  5. Earl
    Replies:
    2
    Views:
    10,379
Loading...

Share This Page