vb.net-以编程方式将图片框添加到tablelayoutpanel

时间:2018-09-05 23:14:03

标签: vb.net visual-studio-2017 picturebox programmatically linklabel

早上全部

我正在以编程方式从数据库中提取行,并将其列出在我的vb.net应用程序中,就像这样...

    Dim linkurl As String = ""
    Dim linkdescription As String = ""
    Dim adapter As MySqlDataAdapter
    Dim hyperlinkresultstable As DataTable
    cn.ConnectionString = connection_string
    Dim commandtext As String
    commandtext = "Select * from mytable where username = '" & "' and type='HYPERLINK';"
    adapter = New MySqlDataAdapter(commandtext, cn)
    hyperlinkresultstable = New DataTable
    adapter.Fill(hyperlinkresultstable)

    For Each row As DataRow In hyperlinkresultstable.Rows
        linkurl = row.Item("value")
        linkdescription = row.Item("description")

        quicklinks_layout.RowStyles.Add(New RowStyle(SizeType.AutoSize))
        quicklinks_layout.RowCount += 1
        quicklinks_layout.Controls.Add(New PictureBox(), 0, quicklinks_layout.RowCount - 1)
        quicklinks_layout.Controls.Add(New LinkLabel(), 1, quicklinks_layout.RowCount - 1)

    Next row

我以前从未以这种方式工作过,我对如何设置添加的Picturebox的'image'属性一无所知。

我还需要能够基于当前行的链接URL和链接描述来设置链接标签的文本值,工具提示值和mouseclick事件。

任何建议或指导表示赞赏!一如既往的感谢! :)

0 个答案:

没有答案