 |
|
ผมทำการ Add UserContor ดึงครั้งแรก ok ครับ ข้อมูลขึ้น แต่พอครั้งที่ 2 Error ครับ |
|
 |
|
|
 |
 |
|
ผมไม่มีปัญหาการ Add ครับ และก็ผมไม่ได้ Add Form ครับ ผม Add UserContor เข้าไปใน Panel ครับ Add กด Button ครัังแรก ผม
สามาถ Add ข้อมมูลเข้ามาทั้งหมด ได้ พอ ทำการ Panel.Controls.Clear() แล้ว Add ใหม่ กับ Error แต่พอลงกับจำนวนข้อมูล 100 รายการไม่มีปัญหา พอเพิ่มข้อมมูล เป็น 400 รายการ มันจะ Add UserContor ได้แค่รอบเดี่ยวครับ พอรอบที่สอง ก็จะ Error อย่างที่เห็นครับ
Code (VB.NET)
Private Sub AllLode()
Panel3.Controls.Clear()
BunifuProgressBar1.Value = 0
Dim table2 As New DataTable
Dim command2 As New SqlCommand(" Select * from " & Manu_Office.COIL1 & " ", connection2)
Dim adapter2 As New SqlDataAdapter(command2)
adapter2.Fill(table2)
For k As Integer = 0 To table2.Rows.Count - 1
Dim DD As New UserDataCoil
Dim A As Integer = 0
A += 1
DD.Name = A
DD.BackColor = Color.White
DD.Dock = System.Windows.Forms.DockStyle.Top
DD.Label2.Text = table2.Rows(k)("SIZE").ToString
DD.Label3.Text = table2.Rows(k)("SPEC").ToString
DD.Label5.Text = table2.Rows(k)("KG").ToString
If Manu_Office.COIL1 = "ST_SHEET" Then
DD.Label4.Text = "PCS."
End If
Me.Panel3.Controls.Add(DD)
Try
TO3 = table2.Rows.Count
BunifuProgressBar1.MaximumValue = TO3
BunifuProgressBar1.Value += Val(A)
If BunifuProgressBar1.Value = TO3 Then
Panel3.Show()
Else
Panel3.Hide()
End If
Catch ex As Exception
End Try
Next
End Sub
|
ประวัติการแก้ไข 2019-04-25 10:57:42
 |
 |
 |
 |
Date :
2019-04-25 10:56:39 |
By :
nutpopo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทั้ง 100 และ 400 คือ จะได้รอบเดียวหมดใช่ไม๊ครับ
แล้วรอบ 2 นี่ มัน Error ตั้งแต่ k = 0 เลยไม๊ครับ
|
 |
 |
 |
 |
Date :
2019-04-25 12:02:19 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปล่าครับ Data 100 ผมสามมารถลีการค้นหา และ Add ลง UserContor ได้ตลอด
แต่ พอต้องการ Add ข้อมูล มากๆ อย่าง 300 หรือ 400 มักจะ Add มาแสดงได้แค่ครั้งเดี่ยว
|
 |
 |
 |
 |
Date :
2019-04-25 13:00:29 |
By :
nutpopo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เกี่ยวกับหน่วยความจำหรือเปล่าครับ คือ Clear() ไม่หมด(อันนี้แค่สมมติฐานนะครับ)
เพราะไม่เคย add control เยอะขนานนั้น
หรือว่าจะลอง add panel ตอนรั้นด้วยก็ได้นะครับ จากนั้น ค่อยทำขั้นตอนต่อไป ส่วนการ clear ก็ทำลายด้วยคำสั่ง dispose ครับ
เพราะจะเป็น clear ทิังไปจาก memory ไปเลยครับ
|
 |
 |
 |
 |
Date :
2019-04-25 17:01:24 |
By :
บัญดิษฐ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลงอง Add Panel เองครับ และก็ลอง dispose ไม่รู้ว่าผมทำถูกมัย พอ dispose แล้ว มันหายไปเลยครับ ทั้ง dispose
ผมไม่เคยใช้ dispose ต้องใช้งานยังไงครับ
Code (VB.NET)
Dim CCS As New Panel
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
CCS.AutoScroll = True
' Me.Panel3.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(192, Byte), Integer))
CCS.Dock = System.Windows.Forms.DockStyle.Fill
CCS.Location = New System.Drawing.Point(0, 47)
CCS.Name = "TTS"
' CCS.Size = New System.Drawing.Size(1247, 734)
''Me.Panel3.TabIndex = 5
BunifuProgressBar1.Value = 0
Dim table2 As New DataTable
Dim command2 As New SqlCommand(" Select * from " & Manu_Office.COIL1 & " ", connection2)
Dim adapter2 As New SqlDataAdapter(command2)
adapter2.Fill(table2)
Me.Controls.Add(CCS)
For k As Integer = 0 To table2.Rows.Count - 1
Dim DD As New UserDataCoil
Dim A As Integer = 0
A += 1
DD.Name = A
DD.BackColor = Color.White
DD.Dock = System.Windows.Forms.DockStyle.Top
DD.Label2.Text = table2.Rows(k)("SIZE").ToString
DD.Label3.Text = table2.Rows(k)("SPEC").ToString
DD.Label5.Text = table2.Rows(k)("KG").ToString
If Manu_Office.COIL1 = "ST_SHEET" Then
DD.Label4.Text = "PCS."
End If
CCS.Controls.Add(DD)
Try
TO3 = table2.Rows.Count
BunifuProgressBar1.MaximumValue = TO3
BunifuProgressBar1.Value += Val(A)
If BunifuProgressBar1.Value = TO3 Then
CCS.Show()
Else
CCS.Hide()
End If
Catch ex As Exception
End Try
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
CCS.Dispose()
End Sub
|
 |
 |
 |
 |
Date :
2019-04-26 08:41:57 |
By :
nutpopo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|