• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

FlowPanelLayout Help

I have the code below that runs on a counter that once it hits 64 buttons on flowpanellayout1 it then adds the rest to flowpanellayout2 what I want to do is have 4 flowpanellayout's and add 64 buttons on each one.

My question is I have managed to split it onto 2 panels but how can I do it for 4 panels?
Dim con As New SqlConnection(My.Settings.Constr)
        con.Open()

        Dim cmd As New SqlCommand("SELECT * FROM tblCostumes WHERE master = '0' order by id", con)
        Dim reader As SqlDataReader = cmd.ExecuteReader()
        Dim counter As Integer = 0

        While reader.Read()
            counter += 1
            Dim btn As New Button
            btn.Name = "Button" & reader("id")
            btn.Width = 116
            btn.Height = 76
            btn.Tag = reader("name")
            btn.Text = reader("name")
            AddHandler btn.Click, AddressOf GetProductDetails

            If counter < 64 Then
                FlowLayoutPanel1.Controls.Add(btn)
            Else
                FlowLayoutPanel2.Controls.Add(btn)
            End If

        End While

Open in new window

0
richard_gar
Asked:
richard_gar
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You could do:

            Select Case counter \ 64 ' Integer Division
                Case 0
                    FlowLayoutPanel1.Controls.Add(btn)
                Case 1
                    FlowLayoutPanel2.Controls.Add(btn)
                Case 2
                    FlowLayoutPanel3.Controls.Add(btn)
                Case 3
                    FlowLayoutPanel4.Controls.Add(btn)
            End Select

LOTS of other ways to do it....
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now