hello again :)
heres the code for declare button:

 Sub table_load()
        Dim CMD As OleDb.OleDbCommand = New OleDb.OleDbCommand("Select * from tblnumber", con)
        Dim rd As OleDbDataReader = CMD.ExecuteReader()
        If rd.HasRows() Then
            Dim pos As New Point(5, 5)
            Dim sz As New Size(50, 50)
            Do While rd.Read()
                Dim tblnum As New Button

                tblnum.Name = "" & rd.Item("ID").ToString()
                tblnum.Text = tblnum.Name
                tblnum.Size = sz
                tblnum.Location = pos


                listtable.Controls.Add(tblnum)

                listtable.ScrollAlwaysVisible = True
                listtable.HorizontalScrollbar = True


                Dim xpos As Integer
                Dim i As Integer
                Math.DivRem(i, 2, xpos)

                If (xpos = 0) Then
                    pos.X = tblnum.Left + tblnum.Width + 5
                Else
                    pos.X = 5
                    pos.Y = tblnum.Top + tblnum.Height + 5
                End If

            Loop
        End If
        rd.Close()
        CMD.Dispose()

    End Sub

[ listtable.ScrollAlwaysVisible = True listtable.HorizontalScrollbar = True , i put this code hoping for scrollbar, please see the photo below to understand more, im not really fluent in english
[i want the other button to be in below of number 1 button]

Recommended Answers

All 4 Replies

Adding more controls than can be shown will not activte the scroll bars. You have to add text to do that.

If you use a panel instead of a listbox and set AutoScroll to True then it will work.

Reverend Jim is correct. Use Panel Control to Hold the Buttons instead of ListBox and set AutoScroll Property to True of the Panel Control.
Make sure in which direction you want to arrange them, Horizontaly/Verticaly and calculate the control's position.

thank you. I got it now. i used flowlayout panel and its working :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.