问一个超级简单的问题!(50分)

  • 主题发起人 主题发起人 chinamaysoft
  • 开始时间 开始时间
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;

代码看起来好像没有问题。但是我在运行时就是不行,按键按下去无效!
 
我是过了代码没问题,要不你试试KeyPress事件
 
Combobox里好像没有Delete的吧,应该是用ComboBox1.DeleteSelected;
 
试了,代码没问题啊
要不就试下 ComboBox 控件
if Key=VK_SPACE then
begin
ComboBox1.ItemIndex:=-1;
end;
if Key=VK_DELETE then
begin
ComboBox1.DeleteSelected;
end;
 
对了,还有个建议
不要用Rz的控件,特别是Rz的DB 控件,问题很大
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部