Thema: Delphi combobox und tastatur

Einzelnen Beitrag anzeigen

DelphiProgrammierer

Registriert seit: 11. Apr 2007
67 Beiträge
 
Delphi 2007 Professional
 
#2

Re: combobox und tastatur

  Alt 11. Mai 2007, 00:57
Mmm... folgender Code funktioniert bei mir, auch wenn etwas selektiert ist (Style is csDropDown). Geht dann auch über die 5 hinaus.

Delphi-Quellcode:
  object ComboBox1: TComboBox
    Left = 160
    Top = 144
    Width = 145
    Height = 21
    ItemHeight = 13
    TabOrder = 2
    Text = '1'
    OnKeyPress = ComboBox1KeyPress
    Items.Strings = (
      '1'
      '2'
      '3'
      '4'
      '5')
  end
Delphi-Quellcode:
procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
  if Key='+then
  begin
    Key := #0;
    ComboBox1.Text := IntToStr(StrToInt(ComboBox1.Text)+1);
  end;
end;
  Mit Zitat antworten Zitat