473,473 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can I size the width of an unnamed column?

My columns in dataGridView3 are generated on the fly from a Select
statement, so I can't set up any columns properties before it is
created. Sort of the way I make them visible or not like the
following:
this.dataGridView3.Columns[0].Visible = false; //id
this.dataGridView3.Columns[1].Visible = false; //parent_id

How can I set the width of Columns[3]?
Any help is appreciated.
Thanks,
Trint

May 31 '07 #1
3 1160
Trint,

Why not just set the Width property on the DataGridViewColumn returned
from the indexer call to Columns? You are already using the Visible
property, if it is visible, then just set the width:

this.dataGridView3.Columns[3].Visible = true;
this.dataGridView3.Columns[3].Width = <your width here>;
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"trint" <tr***********@gmail.comwrote in message
news:11**********************@m36g2000hse.googlegr oups.com...
My columns in dataGridView3 are generated on the fly from a Select
statement, so I can't set up any columns properties before it is
created. Sort of the way I make them visible or not like the
following:
this.dataGridView3.Columns[0].Visible = false; //id
this.dataGridView3.Columns[1].Visible = false; //parent_id

How can I set the width of Columns[3]?
Any help is appreciated.
Thanks,
Trint
May 31 '07 #2
On 31 May, 14:31, trint <trinity.sm...@gmail.comwrote:
My columns in dataGridView3 are generated on the fly from a Select
statement, so I can't set up any columns properties before it is
created. Sort of the way I make them visible or not like the
following:
this.dataGridView3.Columns[0].Visible = false; //id
this.dataGridView3.Columns[1].Visible = false; //parent_id

How can I set the width of Columns[3]?
Any help is appreciated.
Thanks,
Trint
Register for an event called RowDataBound of the grid and in that
event try setting the width of the desired column using
GridViewRowEventArgs event argument.

e.g. e.Row.Cells[0].Width = 100.

May 31 '07 #3
On May 31, 9:45 am, -pb- <prateekb...@gmail.comwrote:
On 31 May, 14:31, trint <trinity.sm...@gmail.comwrote:
My columns in dataGridView3 are generated on the fly from a Select
statement, so I can't set up any columns properties before it is
created. Sort of the way I make them visible or not like the
following:
this.dataGridView3.Columns[0].Visible = false; //id
this.dataGridView3.Columns[1].Visible = false; //parent_id
How can I set the width of Columns[3]?
Any help is appreciated.
Thanks,
Trint

Register for an event called RowDataBound of the grid and in that
event try setting the width of the desired column using
GridViewRowEventArgs event argument.

e.g. e.Row.Cells[0].Width = 100.
Thanks Nicholas... this worked:
this.dataGridView3.Columns[3].Width = <your width here>;
Trint

May 31 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Merlin_1102 | last post by:
I have read previous posts on the gridbaglayout and none seem to answer my questions (sorry if any of these have been aske dI really did search and found one large thread which took me an hour to...
11
by: SarahMarsden | last post by:
I'm new to Dreamweaver (using MX 2004). I have a 2 row 3 column table. I have set each column to 200 pixels. The second row I have merged into one cell. When I enter text (or anything else) into...
1
by: Drew | last post by:
Hey, thanks in advance for helping me out with my problem: I have a datagrid which is embedded in another datagrid. The datagrid is filled directly by a dataset generated from a sql query. So...
12
by: J L | last post by:
When I fill a listview, I resize the columns to fit the data. I need to know if the data will fit vertically or if there will be a vertical scroll bar. I need to know this so I can allow for it on...
2
by: Dominique | last post by:
Hello, Im want to fix the width of a dashboard. I have a field which has a field (in this dashboard on the left part of my screen) which could be long and make the right side of the screen out...
1
by: Nick | last post by:
hi all: the one of the column of gridview got multiple line data to be shown , so how do i deal with it? what i am thinking about is using template field instead of the boundfield. is that...
1
by: cbradio | last post by:
thescripts gurus, I would like to know if I could get some help with making elements of my layout expand (liquid) to the size of their containers, but also allow for some predefined, static...
1
by: RichardR | last post by:
I have a webpage which has a table that contains a column with several drop down boxes (<SELECT>). The contents of the drop down boxes are dynamically populated so I have no idea what the actually...
1
by: thesti | last post by:
hello, i'm trying to design a web. in the header, i create an outer-div which consist of three inner-divs. the html looks like this <div align="center" id="banner-header"> ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.