Get clicked element in acListView

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #37053
    automacaosamos
    Participant

    procedure TFormSamosChat.SpeedButton1Click(Sender: TObject);

    var

    I : Integer;

    ListItem : TacListItem;

    ListGroup : TacListGroup;

    begin

    KssListViewLogin.CheckBoxes := lcNone;

    KssListViewLogin.MultiSelect := False;

    KssListViewLogin.BeginUpdate;

    ListGroup := KssListViewLogin.Groups.Add('Users', 0);

    for I := 1 to 5 do

    begin

    ListItem := ListGroup.Add('');

    ListItem.SubItems.Add('User' + IntToStr(I));

    ListItem.SubItems.Add('Date->' + DateToStr(Date+I));

    end;

    KssListViewLogin.EndUpdate;

    end;

    procedure TFormSamosChat.KssListViewLoginClick(Sender: TObject);

    begin

    ShowMessage(KssListViewLogin.Items.Items[“how do I do”].SubItems[0]);

    end;

    I would select the “UserX”

    I do not get to do

    thank you!!!

    #55306
    KSS
    Participant

    Hello!

    You should use a SelectedItem method in this case.

    Code:
    procedure TFormSamosChat.KssListViewLoginClick(Sender: TObject);
    begin
    if Assigned(KssListViewLogin.SelectedItem) then
    ShowMessage(KssListViewLogin.SelectedItem.SubItems[0]);
    end;
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.