473,500 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Auto Complete Folder Combobox

Does anyone have some sample code for building a combobox that will
automatically list the remaining folders while you type? I'm looking for
functionality similar to the "Look in:" combobox in the Search Companion
panel in Windows Explorer. If you type "C:\" it will open the drop down and
fill it in with all of the directories on C:\. Then as you type letters it
will re-fill the drop down with only the folders that match your typing.

Thanks,
John
Jan 24 '07 #1
3 5718
Since nobody has answered this, I'm going to post a response.
This example is in VB2005 (hey, it's better than nothing).
On the combobox:
Set AutoCompleteMode to SuggestAppend.
Set AutoCompleteSource to CustomSource.

Private Sub LoadManagerComboBox()
If MgrList IsNot Nothing AndAlso MgrList.Count 0 Then
MgrList = Nothing 'blank out the table
End If
MgrList = PTBO.ManagerList.Create("ManagerName")
'bind the combo box to the list
ManagerComboBox.DataSource = MgrList
ManagerComboBox.DisplayMember = "FullName"
ManagerComboBox.ValueMember = "UserID"
ManagerComboBox.SelectedIndex = -1
Call BuildAutoCompleteStrings()
End Sub

Private Sub BuildAutoCompleteStrings()
'If the manager list doesn't have any entries, return.
If MgrList.Count <= 0 OrElse ManagerComboBox.Items.Count <= 0 Then
Return
End If
' Clear what is in there now
ManagerComboBox.AutoCompleteCustomSource.Clear()
'Set the column name.
Dim filterField As String = "FullName"
' Build the list of filter values.
Dim filterVals As AutoCompleteStringCollection = _
New AutoCompleteStringCollection()
For Each dataItem As Object In MgrList
Dim props As PropertyDescriptorCollection = _
TypeDescriptor.GetProperties(dataItem)
Dim propDesc As PropertyDescriptor = _
props.Find(filterField, True)
Dim fieldVal As String = _
propDesc.GetValue(dataItem).ToString()
filterVals.Add(fieldVal)
Next
' Set the list on the collection.
ManagerComboBox.AutoCompleteCustomSource = filterVals
End Sub

Robin S.
------------------------------------------------
"John" <go*******@hotmail.comwrote in message
news:eB**************@TK2MSFTNGP02.phx.gbl...
Does anyone have some sample code for building a combobox that will
automatically list the remaining folders while you type? I'm looking
for functionality similar to the "Look in:" combobox in the Search
Companion panel in Windows Explorer. If you type "C:\" it will open
the drop down and fill it in with all of the directories on C:\. Then
as you type letters it will re-fill the drop down with only the
folders that match your typing.

Thanks,
John

Jan 27 '07 #2
Thanks Robin. I'll check this out tonight. I had sort of given up hope for
an example. I'll post this in C# once I get it working.

John
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:S5******************************@comcast.com. ..
Since nobody has answered this, I'm going to post a response.
This example is in VB2005 (hey, it's better than nothing).
On the combobox:
Set AutoCompleteMode to SuggestAppend.
Set AutoCompleteSource to CustomSource.

Private Sub LoadManagerComboBox()
If MgrList IsNot Nothing AndAlso MgrList.Count 0 Then
MgrList = Nothing 'blank out the table
End If
MgrList = PTBO.ManagerList.Create("ManagerName")
'bind the combo box to the list
ManagerComboBox.DataSource = MgrList
ManagerComboBox.DisplayMember = "FullName"
ManagerComboBox.ValueMember = "UserID"
ManagerComboBox.SelectedIndex = -1
Call BuildAutoCompleteStrings()
End Sub

Private Sub BuildAutoCompleteStrings()
'If the manager list doesn't have any entries, return.
If MgrList.Count <= 0 OrElse ManagerComboBox.Items.Count <= 0 Then
Return
End If
' Clear what is in there now
ManagerComboBox.AutoCompleteCustomSource.Clear()
'Set the column name.
Dim filterField As String = "FullName"
' Build the list of filter values.
Dim filterVals As AutoCompleteStringCollection = _
New AutoCompleteStringCollection()
For Each dataItem As Object In MgrList
Dim props As PropertyDescriptorCollection = _
TypeDescriptor.GetProperties(dataItem)
Dim propDesc As PropertyDescriptor = _
props.Find(filterField, True)
Dim fieldVal As String = _
propDesc.GetValue(dataItem).ToString()
filterVals.Add(fieldVal)
Next
' Set the list on the collection.
ManagerComboBox.AutoCompleteCustomSource = filterVals
End Sub

Robin S.
------------------------------------------------
"John" <go*******@hotmail.comwrote in message
news:eB**************@TK2MSFTNGP02.phx.gbl...
>Does anyone have some sample code for building a combobox that will
automatically list the remaining folders while you type? I'm looking for
functionality similar to the "Look in:" combobox in the Search Companion
panel in Windows Explorer. If you type "C:\" it will open the drop down
and fill it in with all of the directories on C:\. Then as you type
letters it will re-fill the drop down with only the folders that match
your typing.

Thanks,
John


Feb 6 '07 #3
You're welcome.

The irony is, I first saw it in Brian Noyes' Data Binding book, where all
the examples are in C#. It's a great book, if you're doing much data
binding, and it's responsible for the C# I *do* know, because I had to
figure it out to read the book. (I'm sure it made me a better person).

Good luck.
Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
-----------------------------------------------
"John" <go*******@hotmail.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
Thanks Robin. I'll check this out tonight. I had sort of given up hope
for an example. I'll post this in C# once I get it working.

John
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:S5******************************@comcast.com. ..
>Since nobody has answered this, I'm going to post a response.
This example is in VB2005 (hey, it's better than nothing).
On the combobox:
Set AutoCompleteMode to SuggestAppend.
Set AutoCompleteSource to CustomSource.

Private Sub LoadManagerComboBox()
If MgrList IsNot Nothing AndAlso MgrList.Count 0 Then
MgrList = Nothing 'blank out the table
End If
MgrList = PTBO.ManagerList.Create("ManagerName")
'bind the combo box to the list
ManagerComboBox.DataSource = MgrList
ManagerComboBox.DisplayMember = "FullName"
ManagerComboBox.ValueMember = "UserID"
ManagerComboBox.SelectedIndex = -1
Call BuildAutoCompleteStrings()
End Sub

Private Sub BuildAutoCompleteStrings()
'If the manager list doesn't have any entries, return.
If MgrList.Count <= 0 OrElse ManagerComboBox.Items.Count <= 0 Then
Return
End If
' Clear what is in there now
ManagerComboBox.AutoCompleteCustomSource.Clear()
'Set the column name.
Dim filterField As String = "FullName"
' Build the list of filter values.
Dim filterVals As AutoCompleteStringCollection = _
New AutoCompleteStringCollection()
For Each dataItem As Object In MgrList
Dim props As PropertyDescriptorCollection = _
TypeDescriptor.GetProperties(dataItem)
Dim propDesc As PropertyDescriptor = _
props.Find(filterField, True)
Dim fieldVal As String = _
propDesc.GetValue(dataItem).ToString()
filterVals.Add(fieldVal)
Next
' Set the list on the collection.
ManagerComboBox.AutoCompleteCustomSource = filterVals
End Sub

Robin S.
------------------------------------------------
"John" <go*******@hotmail.comwrote in message
news:eB**************@TK2MSFTNGP02.phx.gbl...
>>Does anyone have some sample code for building a combobox that will
automatically list the remaining folders while you type? I'm looking
for functionality similar to the "Look in:" combobox in the Search
Companion panel in Windows Explorer. If you type "C:\" it will open the
drop down and fill it in with all of the directories on C:\. Then as
you type letters it will re-fill the drop down with only the folders
that match your typing.

Thanks,
John



Feb 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2352
by: Maurice Mertens | last post by:
Does anyone know how to get an auto-filling combobox on a form? When I add a combobox to a form I can set the DropDownStyle property to DropDownList. This will make the combobox auto-filling. But...
3
2097
by: Maurice Mertens | last post by:
Hi all, In VB.NET you can set the DropDownStyle for a combobox to 'DropDown' or 'DropDownList'. When you set it to DropDownList, it supports auto-fill. But when you set it to 'DropDown', the...
0
1737
by: george d lake | last post by:
Hi, Is there a way to have a "Auto Complete" textbox or a "editable" dropdown? Here is my problem. I have a screen that need to have a list of 800+ employees. To be a dropdown, that could be a...
8
30390
by: John | last post by:
Hi, I am developing an application using VB.Net and hope that the textbox can process features which are similar to auto-complete features in Window. For example, when user types "ap" in a...
6
2339
by: Smithers | last post by:
I am looking to implement a search feature into a Windows Forms MDI application. Specifically I plan to embed 3 textboxes into a toolbar; one for LastName, another for FirstName, and one for...
1
1451
by: glasssd | last post by:
Hi, I was hoping someone might have some ideas on how I can hack around a problem I'm having with the auto-complete feature of the ComboBox. I have a data entry application that uses a pair of...
3
2435
by: Ronald S. Cook | last post by:
In my Windows forms app, I want my ComboBoxes to let the user begin to type values and it start to populate (if a match is found). But, I don't want the user to enter a value that is not in the...
3
4001
by: TS | last post by:
I am using IE 7. I have a website running on my local machine (localhost) and auto complete doesnt work for any of the textboxes, but going to web sites on the internet does support this so i know...
3
17214
by: Simon van Beek | last post by:
Dear reader, What can be wrong in my ComboBox, the property "Auto Expand" is set to Yes, but by typing in the ComboBox it doesn't expand. Is this because the source of the ComboBox is a...
0
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.