miren en un boton hago una busqueda de un usuario que esta registrado en active directory de windows server 2008 ya lo hace ahora solo quiero que me salga un progresbar al momento que anda buscando al usaurio o usuarios ya que la busqueda se hace por cuentas o por nombres, pero use el reloj de arena del mouse al momento en que busca un usuario. ahora me pidieron que mejor muestre una barra de progreso cuando buisque aqui les dejo el codgigo:
Public Sub Carga(ByVal show As Boolean)
If (show = True) Then
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
Else
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
End If
End Sub
este es cuando el raton pasa a el reloj de arena (metodo usado en internet) ahora el codgio del boton un poquito largo pero ahi va:
Private Sub btnBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuscar.Click
Carga(True)
ListView1.Items.Clear()
Using Searcher As New DirectorySearcher(Root)
If Not (txtnombre.Text.Length + txtape.Text.Length) > 1 Then
Searcher.Filter = "(&(objectCategory=user)(" & ANR & txtCuenta.Text & " * ))"
Else
Searcher.Filter = "(&(objectCategory=user)(givenName=" & txtnombre.Text & "*" & ")(sn=" & txtape.Text & "*" & "))"
End If
Searcher.SearchScope = SearchScope.Subtree
Searcher.PropertiesToLoad.Add("sAMAccountName")
Searcher.PropertiesToLoad.Add("displayName")
Searcher.PropertiesToLoad.Add("givenName")
Searcher.PropertiesToLoad.Add("sn")
Searcher.PropertiesToLoad.Add("distinguishedName")
Searcher.Sort.PropertyName = "sAMAccountName"
Searcher.Sort.Direction = System.DirectoryServices.SortDirection.Ascending
Using users = Searcher.FindAll
If users.Count > 0 Then
Dim item1 As String = Nothing
Dim item2 As String = Nothing
Dim item3 As String = Nothing
Dim item4 As String = Nothing
Dim item5 As String = Nothing
Dim strDisplayName As String = Nothing
For Each user As SearchResult In users
If user.Properties.Contains("displayName") Then
strDisplayName = CStr(user.Properties("displayName").Item(0))
End If
lv = (ListView1.Items.Add(strDisplayName))
If user.Properties.Contains("sAMAccountName") Then
item1 = CStr(user.Properties("sAMAccountName").Item(0))
item1 = "User"
Else
item1 = "Contact"
End If
lv.SubItems.Add(item1)
Try
item2 = CStr(user.Properties("sAMAccountName").Item(0))
Catch
item2 = ""
End Try
lv.SubItems.Add(item2)
Try
item3 = user.Properties("givenName").Item(0).ToString
Catch
item3 = ""
End Try
lv.SubItems.Add(item3)
Try
item4 = user.Properties("sn").Item(0).ToString
Catch
item4 = ""
End Try
lv.SubItems.Add(item4)
lv.SubItems.Add(user.Properties("distinguishedName").Item(0).ToString)
Next
Else
Carga(False)
Exit Sub
End If
End Using
End Using
Carga(False)
End Sub
necesito al dar click al boton que aparezca el progresbar y se quite cuando termine de buscar a los usuarios necesito que el progresbar valla al ritmo de la busqueda XD espero y me puedan entender y/o ayudar gracias