Jump to content
Daniel Ribeiro

Programar botões dinâmicos

Recommended Posts

Daniel Ribeiro

Como consigo programar estes botões que são criados dinamicamente ? 

Ou informação sobre criação de botões dinâmicos

 

 Private Sub compra_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Width = pagina_inicial.Width - 1
        Me.Height = pagina_inicial.Height - 1

        Dim objConexao As SqlClient.SqlConnection
        objConexao = New SqlClient.SqlConnection()
        objConexao.Open()
        '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Dim num_total_pedidos As Integer
        Dim sql As New SqlCommand("SELECT count (*) FROM tbl_pedidos", objConexao)
        num_total_pedidos = sql.ExecuteScalar()
        Dim i, k, x, y As Integer
        x = 63
        y = 20
        For i = 1 To num_total_pedidos
            ' For k = 1 To 4
            Dim btn As New Button
            ' btn.Location = New Point(x, y)
            btn.Width = 100
            btn.Height = 100
            btn.Text = ""
            btn.Visible = True
            FlowLayoutPanel1.Controls.Add(btn)
            btn.Name = "btn" & i
            MsgBox("btn" & i)
            ' x = x + 150
            ' Next
            '  x = 63
            '  y = 150

        Next

        objConexao.Close()

    End Sub

Edited by Daniel Ribeiro

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.