Combobox (50分)

P

panjf

Unregistered / Unconfirmed
GUEST, unregistred user!
有没有办法让ComboBox在没有用鼠标点向下的箭头就弹出列表呢?
我想做出象IE地址栏一样的效果。功能也是和地址栏一样,从一个列表中选择以前输入过的
内容,输入时将经过过滤的历史纪录显示载下拉的列表框里。

有这样的控件也行。

分不多了,请大家谅解
 
ComboBox1.DroppedDown := true;
 
postMessage(Combobox1.handle,CB_SHOWDROPDOWN,1,0);
 
最好的方法是用dxpopup你的问题就解决了
 
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
combobox1.DroppedDown := true;
end;
 
我试过了,可是鼠标的指针却不见了
win2k 个人版,d6
 
只需要将ComboBox的Style属性设定为csOwnerDrawFixed即可,试一试吧!!!!
 
鼠标的指针不要放在combobox1
 
to catchan:
我还要往里输入东西呀,不是就用那里边几个item就行了
 
有什么现成的控件也行呀
 
愚见
combobox1.DroppedDown := true
combobox1.SetFocus;
 
to delphing
还是没鼠标指针呀
 
这个问题已经解决的差不多了,在onkeypress事件中写了如下代码,但在过滤时如果第一次
过滤只剩下1个item的话,下拉列表的DropDownCount就成了1,如果back后重新输入,这次
剩下3个item的话,DropDownCount还是1,各位高手有什么办法改变这个值,让它适应item
的个数

procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
var
s,m: string;
i,j: integer;
begin
if key = #13 then begin
showmessage('回车');
exit;
end;
s := ComboBox1.Text;
case Ord(key) of
VK_ESCAPE: begin
ComboBox1.DroppedDown := false;
ComboBox1.Text := s;
exit;
end;
VK_BACK: begin
ComboBox1.Items.LoadFromFile('./aa.txt');
Delete(s,Length(s),1);
for i := 1 to Length(s) do begin
j := 0;
repeat
m := ComboBox1.Items[j];
if (Length(s) <= Length(m)) and (s = m) then
Inc(j)
else
ComboBox1.Items.Delete(j);
until j = ComboBox1.Items.Count;
end;
ComboBox1.Text := s;
for i := 1 to Length(ComboBox1.Text) do
PostMessage(ComboBox1.Handle, WM_KEYDOWN, VK_RIGHT, 1);
exit;
end;
else
s := s + key;
if s = '' then
ComboBox1.Items.LoadFromFile('./aa.txt');
for i := 1 to Length(s) do begin
j := 0;
repeat
m := ComboBox1.Items[j];
if (Length(s) <= Length(m)) and (s = m) then
Inc(j)
else
ComboBox1.Items.Delete(j);
until j = ComboBox1.Items.Count;
end;
ComboBox1.droppedDown := true;
end;
end;
 
加了一句话搞定,发分喽

VK_BACK: begin
ComboBox1.Items.LoadFromFile('./aa.txt');
Delete(s,Length(s),1);
for i := 1 to Length(s) do begin
j := 0;
repeat
m := ComboBox1.Items[j];
if (Length(s) <= Length(m)) and (s = m) then
Inc(j)
else
ComboBox1.Items.Delete(j);
until j = ComboBox1.Items.Count;
end;
ComboBox1.Text := s;
for i := 1 to Length(ComboBox1.Text) do
PostMessage(ComboBox1.Handle, WM_KEYDOWN, VK_RIGHT, 1);
if ComboBox1.Text = '' then
ComboBox1.DroppedDown := false;
exit;
end;
 
顶部