例如:
  如果我想在ListView控件中选择多条记录信息,然后,在Edit控件中显示我所选种的信息的文本,怎么来实现,使用checkbox = true 来代表多项选择啊,。师兄们给例子吧。
真的很急!

解决方案 »

  1.   

    for  i:=0 to listview1.Items.Count-1 do
    if  listview1.Items[i].Checked:=true  then
      

  2.   

    ListView1.ViewStyle:=vsReport;
    ListView1.GridLines:=True;
      if ListView1.Selected <> Nil then
      begin
        Edit1.text:=ListView1.Selected.SubItems.Strings[0];
        Edit2.text:=ListView1.Selected.SubItems.Strings[1];
         .....
      end;
    快叫师姐.
      

  3.   

    ListView1.CheckBoxes := True;
    只能显示CheckBox,但我发现实际并不能被中。
    看你要多选,应该ListView1.MultuSelect := True;xiaoyan21(明月心) 的代码没错,但实现际上CheckBox无法被选中,而且text文本也覆盖了Checkbox。偶建议你选用GroupBox,将CheckBox动态地放上去。
      

  4.   

    不好意思,偶找到一个方法。Listview1.ViewStyle := vsSmallIcon; //这句很重
    ListView1.Checkboxes := True;
    Listview1.MultiSelect := True;For i:=1 to ListView1.Items.Count-1 do
    begin
         if ListView1.Items[i].Checked then
         begin
             //写你的代码,赋值到Edit.text
             //可参考明月心的代码     end;end;
      

  5.   

    呵..楼上的同志说得很中肯.嗯,不过建议用CheckListBox.
      

  6.   

    //这是用CheckListBox的代码:
    procedure TForm1.Button1Click(Sender: TObject);
    var
      Query:TADOQuery;
    begin
      Query:=TADOQuery.Create(Nil);
      Query.ConnectionString:='';
      Query.SQL.Add('select * from 助学申请 where(日期=#');
      try
        Query.Open;
      except
        MessageDlg('Error',mtError,[mbok],0);
        Query.Close;
        Query.Free;
        exit;
      end;
      Query.First;
      while not Query.Eof do
      begin
        ChecklistBox1.Items.Add(Format('表号[%s] 姓名[%s]',[Fields[0].AsString,Fields[1].AsString]));
        Query1.Next;
      end;
      Query.close;
      Query.free;
    end;