Mastodon
Programmierung

ComboBox fires “KeyPressed” twice – fix

1. TComboBox.OnKeyPress is fired TWICE if style is not csDropDown or csSimple.
Just drop a Combo and a Label. In the Combo OnKeyPress :
label1.Caption:=label1.Caption+Key;
You will see that if you set the style to csDropDownList, the keys you type into the combo are then doubled. ( exists in D4 and D5 NOT in D1)

Workaround : add at the end of your OnKeyPress
[code lang=”delphi”]
if (sender as TComboBox).style not in [csDropDown,csSimple] then
Key:=#0;[/code]

[tags]Delphi, Components[/tags]

0 Kommentare zu “ComboBox fires “KeyPressed” twice – fix

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.