Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 05-07-2006
esocrates esocrates is offline
Miembro
 
Registrado: may 2003
Ubicación: Argentina
Posts: 210
Poder: 21
esocrates Va por buen camino
Propiedad Capacity

Encontré en este hilo:
http://www.clubdelphi.com/foros/showthread.php?t=33311
Una línea de código que no comprendo.
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
  I:Integer;
begin
  if ListBox1.Items.Capacity=0 then
  begin
    for I:=0 to TreeView1.SelectionCount-1 do
    ListBox1.Items.Add(TreeView1.Selections[i].Text);
  end;
end;
Me refiero a la línea que contiene Capacity (la marqué en azul).
Les agradeceré un comentario aclaratorio.
Un saludo y gracias
Responder Con Cita
  #2  
Antiguo 05-07-2006
Avatar de marcoszorrilla
marcoszorrilla marcoszorrilla is offline
Capo
 
Registrado: may 2003
Ubicación: Cantabria - España
Posts: 11.221
Poder: 10
marcoszorrilla Va por buen camino
Pues nos informa de si el ListBox, tiene asignado algún valor o esta vacío.

Un Saludo.
__________________
Guía de Estilo de los Foros
Cita:
- Ça c'est la caisse. Le mouton que tu veux est dedans.
Responder Con Cita
  #3  
Antiguo 05-07-2006
Avatar de marcoszorrilla
marcoszorrilla marcoszorrilla is offline
Capo
 
Registrado: may 2003
Ubicación: Cantabria - España
Posts: 11.221
Poder: 10
marcoszorrilla Va por buen camino
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
 if ListBox1.Items.Capacity = 0 then
 ShowMessage('Vacio')
 else
 Showmessage('Tiene asignados:'+IntToStr(ListBox1.Items.Capacity));
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 if ListBox1.Items.Count = 0 then
 ShowMessage('Vacio')
 else
 Showmessage('Tiene asignados:'+IntToStr(ListBox1.Items.Count));
end;

En estos dos ejemplos, sería lo mismo utilizar Capacity que Count.

Aunque también conviene este apunte de la ayuda de Delphi, porque en algunos casos debe de utilizarse con otros propósitos:
Cita:
Indicates the number of strings the string list has allocated memory to hold.

property Capacity: Integer;

Description

Use Capacity to find out how much memory is available for holding strings, or to reallocate the memory to allow more or fewer strings.

Capacity is the number of entries in the string list that have been allocated, as opposed to Count, which is the number of strings in the list. Thus, Capacity is always greater than or equal to Count.

Adding new strings will cause the Capacity property to increase if necessary, but setting the Capacity property will not change the Count property. Do not set Capacity to a value less than Count, or the list will be truncated and Count will indicate that the list contains more strings than is the case. Also, if Capacity is set to a value less than Count, the memory used to store the strings that are dropped from the list (as opposed to the entries in the list that point to those strings) is not freed.
Un Saludo.
__________________
Guía de Estilo de los Foros
Cita:
- Ça c'est la caisse. Le mouton que tu veux est dedans.
Responder Con Cita
  #4  
Antiguo 05-07-2006
esocrates esocrates is offline
Miembro
 
Registrado: may 2003
Ubicación: Argentina
Posts: 210
Poder: 21
esocrates Va por buen camino
Muchas gracias marcoszorrilla.
Ahora me queda más claro.
Un saludo
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Propiedad del DBGrid Iskariote0087 Varios 3 19-01-2006 15:53:46
Propiedad FocusControl gluglu Varios 11 20-12-2005 18:36:20
propiedad boolean en vcl cuscus OOP 2 24-05-2005 16:27:03
Propiedad del formulario VRO Varios 1 19-10-2004 11:18:44
Propiedad KeyValue i.larranaga Conexión con bases de datos 0 01-10-2004 14:18:07


La franja horaria es GMT +2. Ahora son las 10:35:11.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi