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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagridview column size 2

Status
Not open for further replies.

morfasie

IS-IT--Management
Mar 28, 2004
85
ZA
Hi,

I am trying to set the column size of the datagridview. with the statement : datagridview1.columns[0].width = 20

but it gives me the following error : property access must assign to the property or use its value?


Can anybody help please?
 
If viable in your situation you can look into the AllowAutoColumnFit property as well

____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done
 
Hi,

thanks for replies, unfortunately it is not what I am looking for. I want to adjust one column in a datagridview. If I use, datagridview1.column[0].width = 20, it gives an error?


why is that?

thanks
 
Code:
DataGridView1.Columns(0).Width = [COLOR=red][b]"[/b][/color]20[COLOR=red][b]"[/b][/color]

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Try

DataGridView1.Columns.Item(0).Width = 20

That should do the trick.

Regards,
Noel.
 
Hi Noel,

unfortunately isn't doing anything, not changing the width of the column.



Regards
 
Hi Morfasie,

I actually posted that reply before seeing zmrAbdulla's post. Did his suggestion sort your problem?

If not can you post a copy of your code as i've tested both zmrAbdulla's and my suggestions on a datagrid that i'm working on and it appears to work as you require.

Regards,
Noel.
 
Sorry everybody, stupid me, didn't see that I had the following command before the = "20"

DataGridView3.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells



It works fine now!! Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top