Solved

VB.net DataGridView AutoSizeColumnsMode Issue

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
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 …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now