zoukankan      html  css  js  c++  java
  • Delphi 之 列表框组件(TListBox)

      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.
  • 相关阅读:
    Longest Common Substring
    未完成 Anagrams
    strStr
    vim的学习笔记
    Compare Strings
    Two Strings Are Anagrams
    KMP算法
    [ 力扣活动0314 ] 300. 最长上升子序列
    [ 力扣活动0317 ] 1160. 拼写单词
    [ 力扣活动0313 ] 169. 多数元素
  • 原文地址:https://www.cnblogs.com/delphi2014/p/4028632.html
Copyright © 2011-2022 走看看