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

DataGridView - Property setting

Status
Not open for further replies.

mydisney

Programmer
May 7, 2007
55
US
I have a datagridview that does not allow to resize columns. I have tried to set properties but cannot get it to work. Can anyone tell me what is wrong?

'DataGridView1
'
Me.DataGridView1.AllowUserToAddRows = False
Me.DataGridView1.AllowUserToDeleteRows = False
Me.DataGridView1.AllowUserToOrderColumns = True
DataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
DataGridViewCellStyle1.ForeColor = System.Drawing.Color.Black
DataGridViewCellStyle1.NullValue = "0"
Me.DataGridView1.AlternatingRowsDefaultCellStyle = DataGridViewCellStyle1
Me.DataGridView1.BackgroundColor = System.Drawing.Color.White
Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
DataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft
DataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window
DataGridViewCellStyle2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
DataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText
DataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight
DataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText
DataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.[False]
Me.DataGridView1.DefaultCellStyle = DataGridViewCellStyle2
Me.DataGridView1.Location = New System.Drawing.Point(12, 124)
Me.DataGridView1.Name = "DataGridView1"
Me.DataGridView1.ReadOnly = True
Me.DataGridView1.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.[False]
Me.DataGridView1.Size = New System.Drawing.Size(433, 420)
Me.DataGridView1.TabIndex = 15
 
The datagridview is supposed to allow column resizing by default. You could try commenting out all of your formatting code above and see if you can resize the columns. If so, you can then start the process of elimination and uncomment each line of code until you find the one that is causing the problem. If commenting out the code above doesn't work, post back and we'll go from there.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
This might be you are looking for
Code:
  Me.DataGridView1.AllowUserToResizeColumns = False

________________________________________________________
Zameer Abdulla
Help to find Missing people
 
I'm having the same problem, I have three DGVs on a TabControl, all three are specified identically, but only the DGV on the first tab has resizable columns. I even went into the Designer.Form.vb code and explicitly added Me.DataGridView_Doctor.AllowUserToResizeColumns = True, but no change, the columns are still not resizable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top