Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I set datagrid column to data size?

Status
Not open for further replies.

Nautalus

Programmer
Jun 23, 2002
13
AU
Anybody know how to set the column width in .Net windows forms datagrid?

I want to set it to the width of the data. I can do it from the column header with a mouse but I want to do it programatically.

Any help appreciated.
 
I am new to C#/.Net but had this as one of my first problems. See if you might glean the answer from this code:

this.dataGrid1.TableStyles["Tables"].GridColumnStyles["AccountNumber"].width = (code here to relate the data width to a number of pixels. For example, an 18 digit account number fit well in 100 pixels)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top