17-08-13, 04:19 AM
في الحقيقة انا لم اتعامل مع اداة backworker
يكفيني استعمال الThread
وقد قمت بعمل ذلك في برنامج بالاضافة الى بعض التعديلات الاخرى
لم الرفع البرنامج فاكواده ليست طويلة :
يكفيني استعمال الThread
وقد قمت بعمل ذلك في برنامج بالاضافة الى بعض التعديلات الاخرى
لم الرفع البرنامج فاكواده ليست طويلة :
PHP كود :
Public Class Form1
Dim th As New System.Threading.Thread(AddressOf doFind)
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Try
If (th.ThreadState <> Threading.ThreadState.Unstarted) Then
th.Abort()
th = New System.Threading.Thread(AddressOf doFind)
End If
Catch ex As Exception
End Try
If Not TextBox1.Text.Trim() = "" Then
th.Start()
End If
End Sub
Sub doFind()
Dim txtBox As String = Me.TextBox1.Text
Dim txtLstBox As String
Me.Invoke(New MethodInvoker(Sub()
Me.FlowLayoutPanel1.Controls.Clear()
End Sub))
For y As Integer = 0 To Me.ListBox_0.Items.Count - 1
txtLstBox = Me.ListBox_0.Items.Item(y)
Dim i As Integer
i = InStr(txtLstBox, txtBox, CompareMethod.Text)
If i > 0 Then
Application.DoEvents()
Dim itm As New UserControl1
itm.RichTextBox1.Text = txtLstBox
'
If txtBox <> "" Then
Me.Invoke(New MethodInvoker(Sub()
itm.RichTextBox1.SelectionStart = itm.RichTextBox1.Find(txtBox)
itm.RichTextBox1.SelectionBackColor = Color.Yellow
End Sub))
End If
'
If Me.InvokeRequired Then
Me.Invoke(New MethodInvoker(Sub()
Application.DoEvents()
Me.FlowLayoutPanel1.Refresh()
Me.FlowLayoutPanel1.Controls.Add(itm)
itm.CreateControl()
End Sub))
End If
End If
Next
End Sub
End Class

