Solved

VB.net DataGridView AutoSizeColumnsMode Issue

Posted on 2014-10-30
2
379 Views
Last Modified: 2014-11-02
Hi
I have a DataGridView  where AutoSizeColumnsMode is set to AllCells
I add columns to the DataGridView using the following code. I need the initial
width to be 240 but because there is no initial data the column shrinks.
Is there a way to avoid this?

        Dim DVG1Col As New DataGridViewComboBoxColumn
                DVG1Col.Name = sColumnHeading
                DVG1Col.Width = 240
                DVG1Col.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox
                DVG1Col.HeaderText = sColumnHeading
                Me.DataGridView1.Columns.Add(DVG1Col)
0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40415211
If you change the AutoSizeMode of a specific column, it overrides the default setting given to the whole grid:

DVG1Col.AutoSizeMode = DataGridViewAutoSizeColumnMode.None
0
 

Author Closing Comment

by:murbro
ID: 40418811
thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question