TComboBoxCanvas (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code uses ClientRect to find and draw a line from the upper left to the lower right of the current control. Select a TControl in the ListBox list. This example assumes that the current object is a descendant of TControl and has a public Canvas property.

Code

  if (ListBox1.Items.Objects[Index] is TComboBox) then
  begin
    myComboBox:= (ListBox1.Items.Objects[Index] as TComboBox);
    with myComboBox.ClientRect do
    begin // Make sure you are using the canvas of the TControl, and not the from's canvas
      myComboBox.Canvas.MoveTo(Left, Top);
      myComboBox.Canvas.LineTo(Right, Bottom);
    end;
  myComboBox:= nil;
  end;

Uses