Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.net DataGridView AutoSizeColumnsMode Issue

Posted on 2014-10-30
2
Medium Priority
?
423 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:Murray Brown
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 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:Murray Brown
ID: 40418811
thanks
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

885 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