利用:sendmessage函数。 procedure TForm1.FormCreate(Sender: TObject); var i,maxWidth,width : integer; begin maxWidth:=0; for i:=0 to ComboBox1.Items.Count-1 do begin width := Combobox1.Font.Size*Length(combobox1.Items[i]); if width > maxwidth then maxwidth:=width;//取得最大值 end; combobox1.Text := combobox1.Items[0]; SendMessage(ComboBox1.Handle,CB_SETDROPPEDWIDTH,MaxWidth,0); end;
procedure TForm1.FormCreate(Sender: TObject);
var
i,maxWidth,width : integer;
begin
maxWidth:=0;
for i:=0 to ComboBox1.Items.Count-1 do
begin
width := Combobox1.Font.Size*Length(combobox1.Items[i]);
if width > maxwidth then
maxwidth:=width;//取得最大值
end;
combobox1.Text := combobox1.Items[0];
SendMessage(ComboBox1.Handle,CB_SETDROPPEDWIDTH,MaxWidth,0);
end;
这样子当控件在界面的最右边的时候还是不能全部显示,还有其他什么好的办法吗?