我在使用combobox控件的时候,控件的下来部分的文字的宽度很长(比控件的宽度长很多),不能全部显示,怎么样能够让它在下拉的时候全部显示?

解决方案 »

  1.   

    利用: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;
      

  2.   

    laihecongxi(兴哥) 
    这样子当控件在界面的最右边的时候还是不能全部显示,还有其他什么好的办法吗?