Solved

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

Posted on 2007-04-10
3
430 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

751 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