在vb.net中的面板滚动上动态创建文本框

时间:2016-04-24 13:10:23

标签: vb.net

您好我正在创建10个文本框和组合框作为行来填充销售发票屏幕。用户进入动态创建的最后一个文本框后,我再次填充20行,用户再次输入第29个文本框后,我再创建20行,直到创建了250行,但我仍然坚持应该写哪个事件代码和序列号也无法生成

Private Sub Panel1_Resize(sender As Object, e As System.EventArgs) Handles Panel1.Enter

    Dim viewable As Boolean

    If box5(9).Location.Y < Panel1.Height AndAlso box5(9).Location.Y + box5(9).Height > 0 Then

        viewable = True

    Panel1.HorizontalScroll.Visible = False
    Dim x1 As Integer = 100
    Dim y1 As Integer = 0
    Dim MyLocationX As Integer = 175
    Dim MyLocationY As Integer = 175
    Dim k As Integer

        For i As Integer = 0 To 90
            For j As Integer = 11 To 90

                box5(i) = New TextBox

                box5(i).ReadOnly = True
                box5(i).BackColor = Color.White

                box5(i).Text = 10 + i

            Next j
            k = box5(i).Text
            box5(i).Font = New Font("Times New Roman", 9)
            box5(i).TabStop = False
            box5(i).Location = New System.Drawing.Point(0, 200 + i * 20)
            box5(i).Size = New System.Drawing.Size(55, 26.2)
            box5(i).Multiline = True

            AddHandler box5(i).TextChanged, AddressOf Qty_TextChanged

            Panel1.Controls.Add(box5(i))



            DropDownlist(i) = New ComboBox
            DropDownlist(i).Name = (y1 + 1).ToString
            DropDownlist(i).Location = New Point(55, 200 + i * 20)

            DropDownlist(i).ImeMode = Windows.Forms.ImeMode.KatakanaHalf
            DropDownlist(i).DropDownStyle = ComboBoxStyle.DropDown
            DropDownlist(i).AutoCompleteSource = AutoCompleteSource.ListItems
            DropDownlist(i).AutoCompleteMode = AutoCompleteMode.SuggestAppend
            DropDownlist(i).Font = New Font("Times New Roman", 12)
            DropDownlist(i).Size = New System.Drawing.Size(150, 50)
            AddHandler DropDownlist(i).KeyDown, AddressOf dropdownsearch
            AddHandler DropDownlist(i).GotFocus, AddressOf cbsearch
            Panel1.Controls.Add(DropDownlist(i))
            MyLocationY = MyLocationY + 60
            y1 = y1 + 1





            box6(i) = New TextBox
            box6(i).BackColor = Color.White
            box6(i).Font = New Font("Times New Roman", 12)
            box6(i).Location = New System.Drawing.Point(199, 200 + i * 20)
            box6(i).Size = New System.Drawing.Size(216, 22)
            box6(i).ReadOnly = True
            AddHandler box6(i).GotFocus, AddressOf combo_TextChanged1
            Panel1.Controls.Add(box6(i))
            Dim qty1(100) As Double

            iname(i) = New TextBox
            iname(i).Location = New System.Drawing.Point(412, 200 + i * 20)
            iname(i).Size = New System.Drawing.Size(52, 22)
            iname(i).Font = New Font("Times New Roman", 12)
            Panel1.Controls.Add(iname(i))
            AddHandler iname(i).LostFocus, AddressOf combo_TextChanged3
            AddHandler iname(i).LostFocus, AddressOf combo_TextChanged66
            AddHandler iname(i).LostFocus, AddressOf combo_TextChanged68
            Dim rate1(100) As Double

            exname1(i) = New TextBox
            exname1(i).Location = New System.Drawing.Point(464, 200 + i * 20)
            exname1(i).Size = New System.Drawing.Size(61, 22)
            exname1(i).Font = New Font("Times New Roman", 12)
            rate1(i) = Val(exname1(i).Text)
            Panel1.Controls.Add(exname1(i))




            box2(i) = New TextBox
            box2(i).Location = New System.Drawing.Point(524, 200 + i * 20)
            box2(i).Size = New System.Drawing.Size(70, 22)
            box2(i).ReadOnly = False
            box2(i).BackColor = Color.White
            box2(i).Font = New Font("Times New Roman", 12)
            Panel1.Controls.Add(box2(i))

            gross(i) = New TextBox
            gross(i).Location = New System.Drawing.Point(593, 200 + i * 20)
            gross(i).Size = New System.Drawing.Size(85, 22)
            gross(i).ReadOnly = False
            gross(i).BackColor = Color.White
            gross(i).Font = New Font("Times New Roman", 12)
            Panel1.Controls.Add(gross(i))

            disp(i) = New TextBox
            disp(i).Location = New System.Drawing.Point(675, 200 + i * 20)
            disp(i).Size = New System.Drawing.Size(45, 22)
            disp(i).ReadOnly = False
            disp(i).BackColor = Color.White
            disp(i).Font = New Font("Times New Roman", 12)
            Panel1.Controls.Add(disp(i))

            net(i) = New TextBox
            net(i).Location = New System.Drawing.Point(718, 200 + i * 20)
            net(i).Size = New System.Drawing.Size(97, 22)
            net(i).ReadOnly = False
            net(i).BackColor = Color.White
            net(i).Font = New Font("Times New Roman", 12)
            Panel1.Controls.Add(net(i))

            spc(i) = New TextBox
            spc(i).Location = New System.Drawing.Point(814, 200 + i * 20)
            spc(i).Size = New System.Drawing.Size(127, 22)
            spc(i).ReadOnly = False
            spc(i).BackColor = Color.White
            spc(i).Font = New Font("Times New Roman", 12)
            Panel1.Controls.Add(spc(i))

            exdes(i) = New TextBox
            exdes(i).Location = New System.Drawing.Point(939, 200 + i * 20)
            exdes(i).Size = New System.Drawing.Size(170, 22)
            exdes(i).ReadOnly = False
            exdes(i).BackColor = Color.White
            exdes(i).Font = New Font("Times New Roman", 12)
            Panel1.Controls.Add(exdes(i))

            fullfill(i) = New DateTimePicker
            fullfill(i).Location = New System.Drawing.Point(1107, 200 + i * 20)
            fullfill(i).Size = New System.Drawing.Size(100, 22)
            fullfill(i).CustomFormat = "dd-MM-yy"
            fullfill(i).Format = DateTimePickerFormat.Custom

            fullfill(i).BackColor = Color.White
            fullfill(i).Font = New Font("Times New Roman", 12)
            Panel1.Controls.Add(fullfill(i))

            If (String.IsNullOrEmpty(DropDownlist(i).Text)) Then

                AddHandler DropDownlist(i).LostFocus, AddressOf combo_TextChanged

                AddHandler DropDownlist(i).LostFocus, AddressOf combo_TextChanged2
            Else
                box6(i).Clear()
            End If


        Next i
    Else
        viewable = False
    End If
End Sub

0 个答案:

没有答案