How do i create a list box like the start menu>run command where as the user types a directory name the drop down displays the content of the directory and keeps on changing as the user types.
Printable View
How do i create a list box like the start menu>run command where as the user types a directory name the drop down displays the content of the directory and keeps on changing as the user types.
That would be a ComboBox, not a ListBox. Look at the properties whose names start with "AutoComplete" for that functionality.
Thanks a Lot jmcilhinney, i was using a ComboList Box but didnt know that the autocomplete property did this, i was stupid enough to write code in keypress function of the ComboList Box.
Theres just one more question, can i Filter the file type that are suggested to a particular extention ?? Like i want it to suggest and show only excel files, is that possible
Yes - its all possible. As jmcilhinney says - read up about the autocomplete source and autocomplete mode. That will give you the info you need to implement what you want.
Code:comboBox1.AutoCompleteSource = AutoCompleteSource.FileSystemDirectories
comboBox1.AutoCompleteMode = AutoCompleteMode.Suggest
Yes i have already done that, but i want that the dropdown should suggest excel files only.
How do i filter the suggestion
You'd have to use a custom source and get just the Excel files yourself, using Directory.GetFiles.
Take a look at this custom control from CodeProject, I think it's exactly what you're looking for.
http://www.codeproject.com/KB/cpp/ExpCombo.aspx
Thank you jmcilhinney, keystone_paul and MaximilianMayrhofer for the help you've provided, i've been able to accomplish the task, thanks to your guidance.
Thanks a Ton Again