Solved

VB.net DataGridView AutoSizeColumnsMode Issue

Posted on 2014-10-30
2
386 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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