Hi all...
I am having a little performance issue with the .NET combobox and a SearchResultCollection which hopefully someone can help me to alleviate..
I am basing my SearchResultCollection as an AD (DirectorySearcher) query, I then want to add the returned results into a combobox. At the moment this is very slow...
The query returns about 6000 results depending on the filters being used.
The issue is then adding the items into the combo.. Can anyone help with making this faster?
Thanks in adv for any help.
I am having a little performance issue with the .NET combobox and a SearchResultCollection which hopefully someone can help me to alleviate..
I am basing my SearchResultCollection as an AD (DirectorySearcher) query, I then want to add the returned results into a combobox. At the moment this is very slow...
Code:
ComboBox.Items.Clear()
'Setup the connection to the AD environment to populate our workstation combo
Dim dEntry As New DirectoryEntry(PROV_READ & WKSOU)
Dim dSearch As New DirectorySearcher(dEntry)
'define the filter to use
If Not AllRegions Then
If DRMachines Then
dSearch.Filter = "(&(objectclass=computer)(name=" & machineRegion & "*))"
Else
dSearch.Filter = "(&(objectclass=computer)(name=" & machineRegion & "*)(!name=*DR*))"
End If
Else
If DRMachines Then
dSearch.Filter = "(&(objectclass=computer))"
Else
dSearch.Filter = "(&(objectclass=computer)(!name=*DR*))"
End If
End If
dSearch.SearchScope = SearchScope.OneLevel
dSearch.PageSize = 1000
dSearch.PropertiesToLoad.Add("Name")
'Define a collection to populate
Dim cRESULT As SearchResultCollection
'Execute the query
cRESULT = dSearch.FindAll
Dim oRes As Object
'Query the directory for each workstation and populate the combo
For Each oRes In cRESULT
ComboBox.Items.Add(oRes.Properties("name")(0).ToString)
Next
The query returns about 6000 results depending on the filters being used.
The issue is then adding the items into the combo.. Can anyone help with making this faster?
Thanks in adv for any help.