Solved

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

Posted on 2007-04-10
3
426 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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