C# combobox events

Posted on 2009-04-28
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.

Question by:Ignis2
    LVL 6

    Expert Comment

    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.

    Author Comment

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

    Accepted Solution

    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).

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now