richard_gar
asked on
vb.net Flow layout
I have the following code below that checks my database and then adds buttons to the FlowLayoutPanel. I want to limit the amount of buttons that fit on the flowlayoutpanel to 30 and then if there are more than 30 in the database add the others to flowpanellayout2.
I also want to add 3 buttons to the flowlayoutpanel at the end of my generated buttons how can I do this?
I also want to add 3 buttons to the flowlayoutpanel at the end of my generated buttons how can I do this?
Dim con As New SqlConnection(My.Settings.Constr)
con.Open()
Dim cmd As New SqlCommand("SELECT * FROM tblCostumes WHERE master = '0'", con)
Dim reader As SqlDataReader = cmd.ExecuteReader()
While reader.Read()
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
FlowLayoutPanel1.Controls.Add(btn)
End While
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the buttons i add after the while-loop are the three buttons you wanted to add after the dynamic buttons.
i have added a counter and an if-statement in your while-loop that adds buttons to a different flowlayout if there is more than 30 buttons in the database
i have added a counter and an if-statement in your while-loop that adds buttons to a different flowlayout if there is more than 30 buttons in the database
ASKER
but how can I position the buttons after to be at a certain positioning?
add the buttons to a panel and positioning them there. then add the panel to the flowlayout.
ASKER
Also my code would go on forever.