-
Mar 7th, 2023, 12:33 PM
#1
Thread Starter
Addicted Member
Vb.net cannot change Datagridview column index
I am trying to increase the width of a last dummy column in a datagridview so that I display certain rows after a button click.
The DGV is bigger that the screen so it scrolls, also the forth column is frozen.
I am using the following code :
Code:
Private Sub ButtonHierdieWeek_Click(sender As Object, e As EventArgs) Handles ButtonHierdieWeek.Click
Dim BufferKolomWydte As Integer = 0
For i As Integer = 23 To 32 Step 1
SkeduleringDataGridView.Columns(i).Visible = False
BufferKolomWydte = BufferKolomWydte + SkeduleringDataGridView.Columns(i).Width
Next
BufferKolomWydte = BufferKolomWydte + SkeduleringDataGridView.Columns(12).Width + SkeduleringDataGridView.Columns(13).Width
SkeduleringDataGridView.FirstDisplayedScrollingColumnIndex = 15
SkeduleringDataGridView.Columns(33).AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet
SkeduleringDataGridView.Columns(33).Width = BufferKolomWydte
End Sub
However the column width does not change. I have set the DataGridViewAutoSizeColumnMode to NotSet above.
Is there another setting that I am missing?
-
Mar 8th, 2023, 06:18 AM
#2
Re: Vb.net cannot change Datagridview column index
Hi Gideon,
This might help.
You might like to note that
Code:
For i As Integer = 23 To 32 Step 1
can be written as The index will always be an integer and the step is 1 by default so is only needed if the step is to be something other than 1, (-1, 2, 5 etc.)
Poppa
Last edited by Poppa Mintin; Mar 9th, 2023 at 05:34 AM.
Along with the sunshine there has to be a little rain sometime.
Tags for this Thread
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
|