Solved

DataGridView

Posted on 2016-10-20
2
36 Views
Last Modified: 2016-10-21
VB.NET desktop app.   I'm using DataGridView.  How do I fix the column widths independent of the datasource and the size of the data in each column?  I'm using say width = 200 which seems to work initially, but then when I reset the DataSource property the widths seem to change,
0
Comment
Question by:HLRosenberger
2 Comments
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 41853045
Try      
DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None
'or
For i = 0 To DataGridView1.Columns.Count - 1
    DataGridView1.AutoResizeColumn(i, DataGridViewAutoSizeColumnMode.NotSet)
Next

Open in new window

0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41854387
Thanks did the trick. Thanks!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

832 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