|
-
May 15th, 2013, 05:25 AM
#1
Thread Starter
Frenzied Member
DataGridView AutoSizeColumnsMode Fill Problem
Hi
I'm having a problem when trying to add a column to a datagridview in autosizecolumnsmode set to fill.
After some tests i realize that i can't insert a column to the datagridview. The autosizecolumnsmode it's set at design time.
vb.net Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sqlCon As New SqlConnection("******")
Dim sqlPFs As New SqlCommand("spTest", sqlCon)
Dim adapterPFs As New SqlDataAdapter(sqlPFs)
Dim dtPFs As New DataTable
Dim bs As New BindingSource
sqlPFs.CommandType = CommandType.StoredProcedure
adapterPFs.Fill(dtPFs)
bs.DataSource = dtPFs
DataGridView1.DataSource = bs
If DataGridView1.Columns("Info") Is Nothing Then
Dim colInfo As New DataGridViewImageColumn
With colInfo
.Visible = True
.Name = "Info"
.Frozen = True
.ImageLayout = DataGridViewImageCellLayout.Zoom
.FillWeight = 50
End With
DataGridView1.Columns.Insert(0, colInfo) ////////////WHEN SET TO FILL IT JUMPS OUT HERE
Else
DataGridView1.Columns("Info").Visible = True
End If
End Sub
Rate People That Helped You
Mark Thread Resolved When Resolved
-
May 15th, 2013, 06:06 AM
#2
Re: DataGridView AutoSizeColumnsMode Fill Problem
I haven't tried this, but i'd turn off autosizecolumnsmode, insert a column, then turn autosizecolumnsmode back on...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 15th, 2013, 06:07 AM
#3
Re: DataGridView AutoSizeColumnsMode Fill Problem
I've just noticed your dgv is bound. did you try inserting the column into the datatable?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 15th, 2013, 06:23 AM
#4
Thread Starter
Frenzied Member
Re: DataGridView AutoSizeColumnsMode Fill Problem
I already tried some combinations:
1 - Design to NONE, in the end of the code changed to FILL, columns doesn't adapt at all...
2 - Design to FILL, before adding the column set to NONE, after finishing set to FILL, the columns in the datatable fill the space but the new column doesn't... scrollbar visible.
3 - Design to FILL, before adding the column set to NONE, in the column changed the AutoSizeMode to fill, when the code reaches the addding part it jumps out...
By adding the columns to the datatable directly, should work.
But sometimes by some reason the columns must be added directly to the datagridview without messing with the datatable... and in those situations why we can't add columns when set the auto size columns mode to fill.
Some kind of issue with this combination? Datatable + Fill + Add Column?
Thanks
Rate People That Helped You
Mark Thread Resolved When Resolved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|