all groups > dotnet windows forms > july 2005 >
You're in the

dotnet windows forms

group:

SelectionChangeCommitted event not raised (combobox)


SelectionChangeCommitted event not raised (combobox) Mirzas
7/29/2005 2:42:02 AM
dotnet windows forms: hi,

I have a comboBox with some items inside.
I am implementing a sort-of auto-complete feature so the selectedIndex of
the combobox is being changed while the user is typing text inside.

The problem is: SelectionChangeCommitted event does not fire when user hits
enter, and the selectedindex goes back to -1

Selecting items from the list works ok.

I can force the selectedIndex to the correct value if I hit enter-esc-enter
combination :=)

Any ideas?

using: VS2003, C#

RE: SelectionChangeCommitted event not raised (combobox) Tarun Gujral
7/29/2005 11:56:02 PM
HI

Can go around other way. Try capturing Hit Key event and setting the index ?

--------------------------------------------------------------------------------------

[quoted text, click to view]
RE: SelectionChangeCommitted event not raised (combobox) Mirzas
8/1/2005 12:16:02 AM
The problem is: When I set the index it stays on its previous value..


[quoted text, click to view]
Re: SelectionChangeCommitted event not raised (combobox) vijay
11/16/2005 8:16:31 AM

Hi,
I was doiing some thing simmillar as Mirzas, and i got stuck with th
same problem. When the user type in to the combo (they needed aut
complete, so the typed text was say Op for Open) and hit enter th
combo displayed the closest match properly on the UI, but in the cod
the things were different, the combo text as well as the selectionInde
didn't changed.

The following code is in te Key press event of my control. This fixe
the problem.

-----------------------------------------------------
// Modified below code for fixing the bug that caused typed values i
combo to not persist.

String sTemp = this.Text; // cache the user typed text
int iIndex = this.FindString(sTemp,0); //get the index of the closes
match

this.DroppedDown = false; // close the combo, this will enable the
//combo to get the real index o
the selected item
if (iIndex > -1) //If we have a valid index
{
this.SelectedIndex = iIndex; // set the index
}

-----------------------------------------------------

Hope that helps.

Thanks
Vijay Phulwadhaw

--
vija
-----------------------------------------------------------------------
vijay's Profile: http://www.hightechtalks.com/m27
View this thread: http://www.hightechtalks.com/t219998
AddThis Social Bookmark Button