Solved

VB.net DataGridView AutoSizeColumnsMode Issue

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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 …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

14 Experts available now in Live!

Get 1:1 Help Now