0

大家早,

我以编程方式从数据库中提取行并将它们列在我的 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 的“图像”属性一无所知。

我还需要能够根据当前行的链接 URL 和链接描述设置链接标签的文本值、工具提示值和鼠标点击事件。

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

4

0 回答 0