|
-
Apr 24th, 2016, 12:31 PM
#1
Thread Starter
New Member
Populate text box on panel scroll event
Dynamically creating textbox on panel scroll in vb.net
vb.net
Hi i am creating 10 text boxes and combo boxes as a row to populate a sales invoice screen. after user entering to the last text box dynamically created i am populating again 20 more rows and after user entering the 29th text box again i am creating 20 more rows and it goes untill 250 rows created, but i am stuck on which event should i write the code and serial number also i could not generate
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
-
Apr 24th, 2016, 04:09 PM
#2
Re: Populate text box on panel scroll event
To be honest I see people new to programming try this approach and it is a bit off the wall. The average solution to this sort of situation is to create one input screen. Store the entries in a collection and provide forward and backward buttons so you can display/edit any record you like, delete, or add a new record in your single screen.
If you really feel you must visually show all records in a scrollable list.... I would use a DataGridView Control as it can provide a huge list of entries in one go with no custom programming involved. You could use two columns. One for the row title and one for the data.
Burn the land and boil the sea
You can't take the sky from me
~T
-
Apr 24th, 2016, 04:50 PM
#3
Hyperactive Member
Re: Populate text box on panel scroll event
Using a DGV as Gruff suggested is a good choice, but if you insist on using the TextBoxes and ComboBoxes as you have laid out then I would suggest using a "New Line" button to insert the next line rather than trying to auto-guess what the user wants and adding new lines when you think they are needed. You could even use a NumericUpDown in tandem with the New Line button so users could choose to add multiple lines in one shot. Either way I think guessing and auto creating multiple lines in batches of 20 is a bad idea.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|