5 Replies - 884 Views - Last Post: 30 January 2012 - 07:09 AM Rate Topic: -----

Topic Sponsor:

#1 lashy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-January 12

VS c# Manipulate DataGrid Column Widths

Posted 25 January 2012 - 01:58 PM

Hi,

I am using Visual studio c# aspx forms and i am using a data grid that pulls data from our sql server, this is working fine, but there are a few columns that have quite a bit of data compared to others, e.g firstname, surname, date, problem details etc, the latter being more like a paragraph and i wanted to know if it is possible to alter individual columns widths to suit. My first week on C# so any help would be great.

If there is a way a small example would be appreciated.

Cheers

Is This A Good Question/Topic? 0
  • +

Replies To: VS c# Manipulate DataGrid Column Widths

#2 Sergio Tapia  Icon User is offline

  • Is that a raincoat?
  • member icon

Reputation: 1012
  • View blog
  • Posts: 3,816
  • Joined: 27-January 10

Re: VS c# Manipulate DataGrid Column Widths

Posted 25 January 2012 - 02:50 PM

Something like:

DataGridViewColumn column = dataGridView.Columns[0];
column.ItemStyle.Width = 60;



See the official Docs for more:
msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.width.aspx

This post has been edited by Sergio Tapia: 25 January 2012 - 02:51 PM

Was This Post Helpful? 0
  • +
  • -

#3 RexGrammer  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 152
  • View blog
  • Posts: 664
  • Joined: 27-October 11

Re: VS c# Manipulate DataGrid Column Widths

Posted 26 January 2012 - 02:56 AM

Strangely but the URL parser won't parse the URL unless you out http:// in front of the address. (At least in my case: I'm using Chrome)

DataGridViewColumn.Width Property

This post has been edited by RexGrammer: 26 January 2012 - 02:58 AM

Was This Post Helpful? 0
  • +
  • -

#4 lashy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-January 12

Re: VS c# Manipulate DataGrid Column Widths

Posted 26 January 2012 - 03:42 PM

Thanks for the reply,

I forgot to add this is an aspx web form and i cannot see DatGridView in the Toolbox, would this still be the same syntax? or should i be using/ looking for something else.

Thanks
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is online

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1449
  • View blog
  • Posts: 5,761
  • Joined: 21-March 08

Re: VS c# Manipulate DataGrid Column Widths

Posted 26 January 2012 - 04:22 PM

This is why we have an ASP.Net forum. For ASP.Net questions, please post in this forum. There is a huge difference between ASP.Net and WinForms. One is that ASP.Net doesn't have a DataGridView. It has a DataGrid(back from .Net 1.1) and a GridView(you should use this one).
Was This Post Helpful? 0
  • +
  • -

#6 lashy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-January 12

Re: VS c# Manipulate DataGrid Column Widths

Posted 30 January 2012 - 07:09 AM

Apologies,

Will post in the ASP.net side ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1