2016-11-14 92 views
0

我想动态地在vb.net中创建一个按钮。我正在一家餐厅的销售点工作。有关如何完成的任何想法?它有一个数据库。你有没有关于如何制作餐厅销售点的想法?在vb.net中用数据库创建一个动态按钮

我试图搜索一些样本,但找不到正确的过程。

+1

1.'有关如何完成的任何想法?**是**。 2.“你对如何制作餐厅销售点有任何想法吗?”**是**。我对你遇到的任何问题都没有特别的问题。请更新您尝试过的方式以及卡住的位置。我们不是自由编程站点。 – Codexer

+0

我知道如何制作它!只需从现有供应商购买软件,不用担心按钮。 –

回答

-1
Dim PointButton As Point = New Point 
    Try 
     cn = MySQLi.MySQLConnectionMobile 
     Query = "SELECT `table` FROM `last_sync`" 
     da = New MySqlDataAdapter(Query, cn) 
     ds = New DataSet 
     ds.Clear() 
     da.Fill(ds, Table) 

     ReDim MyButton(ds.Tables(0).Rows.Count) 

     Dim one As Integer = 1 
     For i = 0 To ds.Tables(0).Rows.Count - 1 
      MyButton(i) = New Button 
      MyButton(i).Text = ds.Tables(0).Rows.Item(i).Item(0).ToString 
      MyButton(i).Name = "Table" & one.ToString 
      MyButton(i).BackColor = Color.Transparent 
      PointButton.Y = 3 
      If one = 1 Then 
       PointButton.X = PointButton.X 
      Else 
       PointButton.X = PointButton.X + MyButton(i).Width + 10 
      End If 
      MyButton(i).Location = PointButton 

      DirectCast(main_junk.Panel2, Panel).Controls.Add(MyButton(i)) 
      one += 1 
      AddHandler MyButton(i).Click, AddressOf main_junk.Button_Click 
     Next 
    Catch ex As Exception 
     MsgBox(ex.Message, MsgBoxStyle.Critical, "Uknow Databases") 
    End Try 

其中main_junk是一种形式。 和这一个处理程序

Public Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 
    'YOUR CODE HERE 
End Sub