Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread TButtonComboBox - DropDownWidth property
Wed, Apr 25 2018 3:27 AMPermanent Link

Paul Coshott

Avatar

Hi All,

I need to simulate a button menu, so I put a button next to a TButtonComboBox, which works and looks really good, except for the drop down width. The TButtonComboBox component width is only 33, but I need the drop down menu to be much wider.

Is there any way to do this?

Thanks,
Paul
Wed, Apr 25 2018 11:40 AMPermanent Link

Uli Becker

Paul,

> Is there any way to do this?

This is the code in "webedits.wbs" which is responsable for that:

procedure TComboListControl.DoOpen(APosition: TDropDownPosition;
                                   AItemCount: Integer; const AText:
String);
{$IFNDEF DESIGN}
var
   TempControl: TControl;
   TempSurface: TControl;
{$ENDIF}
begin
   {$IFNDEF DESIGN}
   BeginUpdate;
   try
      TempControl:=TControl(Owner);
      TempSurface:=TempControl.GetSurface;
      Parent:=TempSurface;
      Width:=TempControl.Width;

Height:=((Min(AItemCount,Items.Count)*ItemHeight)+(Height-ClientHeight));
      case APosition of
         dpRelative:
            begin
            Left:=TempControl.SurfaceLeft;
            Top:=(TempControl.SurfaceTop+TempControl.Height);
            { Make sure that the drop down list fits on the surface }
            if ((Top+Height) > TempSurface.Height) then
               Top:=((Top-TempControl.Height)-Height);
            end;
         dpSurfaceCenter:
            Layout.Position:=lpCenter;
         end;
      DoNearFind(AText);
      BringToFront;
      Show;
   finally
      EndUpdate;
      { We want to set focus *after* everything is updated !!! }
      SetFocus;
   end;
   {$ENDIF}
end;

You would have to modify this line:

      Width:=TempControl.Width;

Or create a custom control which is able to control the width of the
list item. Smile

Cheers Uli
Wed, Apr 25 2018 11:47 AMPermanent Link

Uli Becker

Addition: why don't you just use a listbox control next to the button?
Image