?
Solved

C# combobox events

Posted on 2009-04-28
3
Medium Priority
?
394 Views
Last Modified: 2012-06-27
Hi there,
I have an editable combo box(style = dropdown); can anyone tell me what event fires when the user types in text into the combo as opposed to selecting one from the existing list please?
Is there a common event that works for both? The SelectedIndexChanged property didn't seem to fire for the text change.

Thanks!
0
Comment
Question by:Ignis2
  • 2
3 Comments
 
LVL 6

Expert Comment

by:alex_paven
ID: 24252443
As far as I know there's no event that does that; you'll need to handle the KeyDown event (or PreviewKeyDown) to detect when the user types. The SelectedIndexChanged is fired, I think, if the autocomplete source is set to ListItems and the user enters a string that fully matches one of the items. Other than that, you'll either need to handle the events separately or inherit the ComboBox in a class of your own and raise events how you see fit - however, note that it's illogical to fire SelectedIndexChanged when a key is pressed.
0
 

Author Comment

by:Ignis2
ID: 24258208
But is there any way of knowing when he has completed typing in the text? The textupdate event keeps firing in between!
0
 
LVL 6

Accepted Solution

by:
alex_paven earned 500 total points
ID: 24258248
Well, 'completed typing the text' sounds awfully vague :)
One option would be to simply wait until the focus leaves the control - then you know for sure; if however you need to provide some feedback before leaving the control, you can implement a timeout function: whenever the user types something, start a timer; if the user types something more before the timer is elapsed (with an interval of say 500-1000 ms), restart the timer; when the timer is elapsed, do your action (you can assume the user stopped typing because he's finished or waits for feedback).
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Integration Management Part 2
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question