How to perform incremental searching on CheckListBox and Combo Box

I want to searching like you search in a folder. I will press more tha

Page 1 of 1

1 Replies - 2123 Views - Last Post: 04 August 2009 - 09:54 PM Rate Topic: -----

#1 ashokruhela   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-August 09

How to perform incremental searching on CheckListBox and Combo Box

Post icon  Posted 04 August 2009 - 08:42 PM

Hi All,

I want to searching like you search in a folder. I will press more than on character consecutively and matching item should be selected. How can I perform this kind of functionality. Where to write code for this

Thanks,
Ashok Kumar
Is This A Good Question/Topic? 0
  • +

Replies To: How to perform incremental searching on CheckListBox and Combo Box

#2 janne_panne   User is offline

  • WinRT Dev
  • member icon

Reputation: 428
  • View blog
  • Posts: 1,047
  • Joined: 09-June 09

Re: How to perform incremental searching on CheckListBox and Combo Box

Posted 04 August 2009 - 09:54 PM

I would write the code in KeyPress events of both controls. You can then use FindString() method of the controls to look for specific item which starts with a string you pass to FindString().

		string vSearch = "";

		private void checkedListBox1_KeyPress(object sender, KeyPressEventArgs e)
		{
			vSearch += e.KeyChar.ToString();
			checkedListBox1.SelectedIndex = checkedListBox1.FindString(vSearch);
		}



Just remember to add some timer or something to clear the searchstring after a second or few so that user can start a new search without restarting the whole application.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1