Accomplish gallery-type display with a Windows Forms data control and DataTable?

前端 未结 3 1642
粉色の甜心
粉色の甜心 2021-01-27 02:29

I have a datatable that looks like the following:

Room   Cook   Waiter  BG_Image
----------------------------------
201    Joe    Jim     Green.png
         


        
3条回答
  •  没有蜡笔的小新
    2021-01-27 03:08

    Here's some VB code to add an array of textboxes to a FlowLayoutPanel:

    Sub AddMany(cols As Integer, rows As Integer)
        Dim txt As TextBox
        FlowLayoutPanel1.FlowDirection = FlowDirection.LeftToRight
        FlowLayoutPanel1.AutoScroll = True
        For y As Integer = 0 To rows - 1
            For x As Integer = 0 To cols - 1
                If Not (x = 0 And y = 0) Then
                    txt = New TextBox
                    txt.Text = "txt_" & y & "_" & x
                    txt.Name = "txt_" & y & "_" & x
                    FlowLayoutPanel1.Controls.Add(txt)
                    AddHandler txt.KeyDown, AddressOf MoveKeyDown
                    AddHandler txt.DoubleClick, AddressOf ShowMeta
                End If
            Next
            FlowLayoutPanel1.SetFlowBreak(txt, True)
        Next
    End Sub
    

    Instead of simple TextBoxes you could add Buttons with images or PictureBoxes. You'd have to paint the text onto the images - or use a custom control.

提交回复
热议问题