connectionlist Items property
Return to Introduction  Previous page  Next page
Applies to
acConnectionList component.  

Declaration
property Items[Index: Integer]: TacConnection read Get; default// read-only!  

Description
The Items is the run-time only property, which can be used to get an access to each instance of TacConnection object (which contains the information about the connection) at particular position. Index gives the position of the TacConnection object, where 0 is the position of the first connection, 1 is the position of the second connection, and so on ("Count - 1" is the position of last process in the list).  
 
Items is the default property of acConnectionList component. The Items identifier can be omitted when accessing the TacConnection objects. For example, the following two lines of code are both acceptable and do the same thing:  
FirstConnection := acConnectionList1.Items[0];  
FirstConnection := acConnectionList1[0];  
 
To determinate the number of items which currently are available in the list — read Count property.  

Example
// Demonstrates how to retrieve the list of processes and display them in the ListView:  
procedure TForm1.Button1Click(Sender: TObject);  
var  
  I: Integer;  
  ListItem: TListItem;  
begin  
  acConnectionList1.Refresh// refreshing the list of processes  
 
  ListView1.Items.BeginUpdate;  
  try  
    ListView1.Items.Clear;  
    I := acConnectionList1.Count;  
    if I <> 0 then  
     for I := 0 to I - 1 do  
      begin  
       ListItem := ListView1.Items.Add;  
       ListItem.Caption := acConnectionList1[I].LocalIPStr + IntToStr(LocalPort));  
       ListItem.SubItems.Add(acConnectionList1[I].RemoteIPStr + IntToStr(RemotePort));  
 
       // ...optionally, let's associate the Data pointer to TacProcess object  
       // and Data pointer of Process object to ListItem  
       ListItem.Data := acConnectionList1[I];  
       acConnectionList1[I].Data := ListItem;  
      end;  
  finally  
    ListView1.Items.EndUpdate;  
  end;  
end;  

See also
Count property.