如何讓listbox中某一行隱藏?
或者讓某一行不能選中。

解决方案 »

  1.   

    是不是可以这样:
    for i:=0 to listbox1.items.count-1 do
     if not listbox1.selected[你不想选中的那项] then//当选中的不是你希望不能选中的那项则做以下工作
      begin
        if listbox1.selected[i] then
        .
        .
        .
      end
      else
      showmessage('此项不能操作!');
      

  2.   

    请问:如何控制listbox内字段的垂直间距?
      

  3.   

    定义一个变量NeedHide表示你要隐藏的项,然后写ListBox的OnDrawItem事件:
    procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;  Rect: TRect; State: TOwnerDrawState);
    var
      S:string;
    begin
      s:=(Control as TListbox).Items[Index];
      ListBox1.Canvas.FillRect(RECT);
      DrawText((Control as TListbox).Canvas.Handle,
                pchar(s),
                Length(s),
                Rect,
                DT_Left OR DT_SingleLine);
      if NeedHide=Index then
        ListBox1.Canvas.FillRect(RECT);//覆盖掉这一行    
    end;
      

  4.   

    1。
    procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
      var Height: Integer);
    begin
      height:=200;//控制行高
    end;
    2。
    procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    begin
    //其中控制隐藏,就象楼上老兄说的
    end;
    3。看看你的可用分
      

  5.   

    这样行吗?
    例如:让第i行不被选中if Listbox1.ItemIndex=i-1 then Listbox1.Selected[i-1]:=false;
      

  6.   

    procedure TForm1.ListBox1Click(Sender: TObject);
    begin
       if listbox1.ItemIndex=i-1 then Listbox1.selected[i-1]:=false;
    end;end.
      

  7.   

    对 忘了写了 要在onClick中