C
chinamaysoft
Unregistered / Unconfirmed
GUEST, unregistred user!
对于一个Combobox。我想实现下面的效果。如果按Delete键就删除当前Combobox1显示的内容,按空格键,就将当前Combobox1显示的内容清空(但是不删除)。我是这样做的,但是不行
procedure TMainForm.RzComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_SPACE then
begin
RzComboBox1.ItemIndex:=-1;
end;
if Key=VK_DELETE then
begin
RzComboBox1.Delete(RzComboBox1.ItemIndex);
end;
end;
代码看起来好像没有问题。但是我在运行时就是不行,按键按下去无效!
procedure TMainForm.RzComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_SPACE then
begin
RzComboBox1.ItemIndex:=-1;
end;
if Key=VK_DELETE then
begin
RzComboBox1.Delete(RzComboBox1.ItemIndex);
end;
end;
代码看起来好像没有问题。但是我在运行时就是不行,按键按下去无效!