• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Delphi之列表框组件(TListBox)

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

  TListBox组件属性

AutoComplete

  设置是否将焦点移到用户键盘输入选项上

BorderStyle

  设置组件是否有边框

Canvas

  提供一个绘图面板。

Columns

  指定列表框的可见列数

Count

  获得列表框的组件选项数

ExtendedSelect

  是否可以在列表框中选取一个范围的选项

IntegralHeight

  设置列表框是否部分显示那些显示不全的选项

ItemHeight

  设置列表框的高度

Items

  设置列表框的所有选项

MultiSelect

  是否使用多项选择功能

ScrollWidth

  指定列表框的宽度

SeltCount

  返回当前选项中的总数

Sorted

  设置列表框选项释放按字母排序

Style

  设置列表框的风格

TabWidth

  设置Tab的宽度

TopIndex

  设置选项中顶端的索引编号

示例:自动获取列表框中的组件焦点

procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  i:Integer;
begin
   for i:= 1 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.

示例 用Canvas属性绘图

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  i:integer;
begin
  with Control as TListBox do
  begin
    Canvas.FrameRect(Clientrect);
    if odSelected in State then
    begin
      Canvas.Brush.Color:=clRed;
      Canvas.RoundRect(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,8,15);
      setBkMode(Canvas.Handle,TRANSPARENT    );
      Canvas.TextOut((Rect.right-Rect.Left) div 2,Rect.Top,Items.Strings[Index]);
    end
    else
    begin
      Canvas.Brush.Color:=clSkyBlue;
      Canvas.RoundRect(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,15,15);
      Canvas.TextRect(Rect,Rect.Left,Rect.Top,Items.Strings[Index]);
    end;
  end;
end;


end.

示例 模糊查找文字

procedure TForm1.Edit1Change(Sender: TObject);
var
  LIndex:Integer;
begin
  LIndex:=SendMessage(ListBox1.Handle,LB_SELECTSTRING,-1,LongInt(Edit1.Text));
end;

end.

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
DelphiDBGrid实现多选和获取多选的值发布时间:2022-07-18
下一篇:
DELPHI10.3.1安卓照相发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap