VB Express 2008

  • Thread starter Thread starter fargodwe
  • Start date Start date
F

fargodwe

Guest
I have a folder full of jpg files. Some of these would only match on"CARD*.jpg" by the user pressing 1 button. All of the files except the "CARD*.jpg" would match when the user selects another button.

I am a novice at this so I have gotten help from the vb forums, but can't get answer to this:

I have a tablelayoutpanel on my form. I create a listof type picturebox and load it with the images from the button click then using TableLayoutPanel.Controls.AddRange(pictureBoxes.ToArray()) to create an array of those pictureboxes in the tablelayoutpanel, In designer I have the tablelayoutpanel defined as having 4 columns, all a 25% of the width, 2 rows of 310 high and autoscroll set to true. So, the first time through if there are 35 non-"CARD" images it shows at runtime just fine with a vertical scrollbar to get to all the entries. If the user then clicks the other button only the "CARD" images show. There is only 6 of those files in the folder. I do a TableLayoutPanel.Controls.Clear() to remove the old images, set the rowcount to 2 and then fill the list and load it again as an array into the tablelayoutpanel. I set the scroll to 1 so the scroll bar is back at the top. The problem? The scroll area remains the same as the larger size so even though there would only be 2 rows there is a huge scroll area as if the size is still the same as when the larger number of images was added. This is the subroutine that does the loading of the list when the files are of type "CARD".

Private Sub DO_BY_CARD(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BY_CARD.Click


Dim myfile As Integer = 0

Dim myfile_path As String
myfile_path = INSTALLATION_FOLDER & CARD_IMAGES_PATH

Dim maxcount As Integer = 0
Dim maxcount_cardimages = 0

Dim xx As Integer = 0
Dim wrkint As Integer = 0

Dim oldrowcount As Integer = 0
Dim currentrowcount As Integer = 0

Dim filePaths = IO.Directory.GetFiles(myfile_path, "card*.jpg")

maxcount = UBound(filePaths)


SELECT_GAME.Text = "Play Card"
SELECT_GAME.Enabled = True
SELECT_GAME.Visible = True


If maxcount_cardimages > 0 Then
ReDim CARDIMAGES(maxcount)
Else
ReDim CARDIMAGES(1)
End If


CARDIMAGES = filePaths

TableLayoutPanel1.Height = 628
TableLayoutPanel1.Width = 1120
TableLayoutPanel1.VerticalScroll.Value() = 1

For Each pb As PictureBox In TableLayoutPanel1.Controls.Cast(Of Control).ToArray()
pb.Dispose()
Next

TableLayoutPanel1.Controls.Clear()

TableLayoutPanel1.RowCount = maxcount / TableLayoutPanel1.ColumnCount

If (maxcount Mod TableLayoutPanel1.ColumnCount) > 0 Then
TableLayoutPanel1.RowCount += 1
End If

Dim pictureBoxes As New List(Of PictureBox)

If maxcount > 0 Then
xx = maxcount \ TableLayoutPanel1.ColumnCount
If (maxcount Mod TableLayoutPanel1.ColumnCount) > 0 Then
xx += 1
End If
TableLayoutPanel1.RowCount = xx
End If


For myfile = 0 To maxcount
Dim pb As New PictureBox With {.Width = 280, _
.Height = 310, _
.ImageLocation = CARDIMAGES(myfile), _
.SizeMode = PictureBoxSizeMode.StretchImage, _
.Name = myfile}
AddHandler pb.Click, AddressOf BOX_CLICKED
pictureBoxes.Add(pb)
Next

TableLayoutPanel1.Controls.AddRange(pictureBoxes.ToArray())

TableLayoutPanel1.Enabled = True
TableLayoutPanel1.Visible = True


End Sub

Any help would be greatly appreciated. I need to still generate code for an old old laptop with Windows Media Center edition on it. I tried using Visual Studio Community Edition 2017 but it comes up with some file missing that stops from starting debugging:

Severity Code Description Project File Line Suppression State Suppression State
Error An error occurred while signing: Failed to sign bin\Release\app.publish\BINGO.exe. SignTool Error: Signtool requires CAPICOM version 2.1.0.1 or higher. Please
copy the latest version of CAPICOM.dll into the directory that contains
SignTool.exe. If CAPICOM.dll exists, you may not have proper
permissions to install CAPICOM. BINGO

Continue reading...
 
Back
Top