Tlistbox Component Properties
AutoComplete
Sets whether to move the focus to the user's keyboard input option
BorderStyle
Set whether the component has a border
Canvas
Provides a drawing panel.
Columns
Specify the number of visible columns for a list box
Count
Get the number of component options for a list box
Extendedselect
Whether you can select a range of options in the list box
IntegralHeight
Sets whether the list box partially displays the options that are not fully displayed
ItemHeight
Set the height of a list box
Items
Set all options for a list box
MultiSelect
Whether to use the multiple selection feature
ScrollWidth
Specify the width of the list box
Seltcount
Returns the total number of current options
Sorted
Set list box options to release alphabetical order
Style
Set the style of a list box
Tabwidth
Set the tab width
TopIndex
Set the index number at the top of the option
Example: Automatically get the component focus in a list box
var Key:word; Shift:tshiftstate); var i:integer;begin for1 to Length (Trim (edit1.text)) do SendMessage (Listbox1.handle,wm_char,integer (Edit1.text[i]),0); SendMessage (Listbox1.handle,wm_char,integer (Key),0); end;end.
Example drawing with canvas properties
procedure Tform1.listbox1drawitem (Control:twincontrol; Index:integer; Rect:trect; State:townerdrawstate);varI:integer;begin with Control asTlistbox Dobegin Canvas.framerect (clientrect); ifodselectedinchState then begin Canvas.Brush.Color:=clred; Canvas.roundrect (Rect.left,rect.top,rect.right,rect.bottom,8, the); SetBkMode (canvas.handle,transparent); Canvas.textout ((Rect.right-rect.left) Div2, Rect.top,items.strings[index]); EndElsebegin Canvas.Brush.Color:=Clskyblue; Canvas.roundrect (Rect.left,rect.top,rect.right,rect.bottom, the, the); Canvas.textrect (Rect,rect.left,rect.top,items.strings[index]); End End;end;end.
Example Blur find text
procedure Tform1.edit1change (sender:tobject); var lindex:integer;begin LIndex:=sendmessage (listbox1.handle,lb_selectstring,-1, Longint (Edit1.text)); end;end.
Delphi's list box component (Tlistbox)