Solved

C# - Forcing column in DataGridView to stay at specified width

Posted on 2007-04-10
3
425 Views
Last Modified: 2008-02-01
Hi guys 'n gals,

Is it at all possible to force a column in a DataGridView to stay at a certain width, so that the user cannot manually resize it? If so, what code do I need to do this?


Cheers!
0
Comment
Question by:Cyber-Drugs
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
CBeach1980 earned 500 total points
ID: 18884645
To keep the user from being able to resize it:
DataGridView.AllowUserToResizeColumns = false;

To set the width to a particular size:
DataGridView.Columns["TargetColumn"].Width = 100;
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18884940
Brilliant, wasn't sure if I could do that for a specific column or if it would have to be the entire DataGridView, thanks once again!
0
 
LVL 4

Expert Comment

by:CBeach1980
ID: 18884959
Again you are more than welcome.  Glad to be of help.
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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

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

18 Experts available now in Live!

Get 1:1 Help Now