Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 18-04-2012
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola angelp4492.

Obtener el valor seleccionado mediante el click/doble click no es tan sencillo como en otros controles, por ejemplo un TStringGrid:
Código Delphi [-]
procedure TForm1.StringGrid1Click(Sender: TObject);
begin
  Caption:= StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row];
end;
Ya que el evento OnClick del TListView se dispara ante cualquier click en el área cliente del control; pero dada la multiplicidad de estilos el click puede ser echo en una etiqueta, un ícono, un state icon,..,o en nada. Por otro lado tenemos que la propiedad SubItems de TListItem es de tipo TStrings.

Con la función GetHitTestInfoAt del TListView podemos obtener información de donde fue hecho el click y de ese modo obtener los SubItems del TListItem (si el click fué hecho sobre alguno).
Código Delphi [-]
function GetListViewItem(LV: TListView): TStrings;
var
  HitTests: THitTests;
  P: TPoint;
begin
  P:= LV.ScreenToClient(Mouse.CursorPos);
  HitTests:= LV.GetHitTestInfoAt(P.X,P.Y);
  Result:= TStringList.Create;
  if HitTests <= [htOnIcon, htOnItem, htOnLabel, htOnStateIcon] then
    Result:= LV.Selected.SubItems
end;

Llamada de ejemplo:
Código Delphi [-]
procedure TForm1.ListViewClick(Sender: TObject);
begin
  ListBox1.Items:= GetListViewItem(ListView)
end;


Tu pregunta inicial fué sobre seleccionar un SubItem, pero lamentablemente no conozco la forma de conocer por ejemplo, sobre cuál SubItem de un ListView con ViewStyle = vsReport fué hecho el click. Cuando se hace un click sobre un SubItem el valor obtenido es htNowhere, cosa fácil de comprobar agregando, este código al evento OnClick del TViewList:
Código Delphi [-]
procedure TForm1.ListViewClick(Sender: TObject);
var
  HitTests: THitTests;
  P: TPoint;
begin
  P:= ListView.ScreenToClient(Mouse.CursorPos);
  HitTests:= ListView.GetHitTestInfoAt(P.X,P.Y);
  with ListBox1.Items do
  begin
    if htAbove in HitTests then Add('htAbove');
    if htBelow in HitTests then Add('htBelow');
    if htNowhere in HitTests then Add('htNowere');
    if htOnItem in HitTests then Add('htOnItem');
    if htOnButton in HitTests then Add('htOnButton');
    if htOnIcon in HitTests then Add('htOnIcon');
    if htOnIndent in HitTests then Add('htOnIndent');
    if htOnLabel in HitTests then Add('htOnLabel');
    if htOnRight in HitTests then Add('htOnRight');
    if htOnStateIcon in HitTests then Add('htOnStateIcon');
    if htToLeft in HitTests then Add('htToLeft');
    if htToRight in HitTests then Add('htToRight');
  end;
end;
Espero te ayude en algo.

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
 



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
validar un subitem listview victor2023 OOP 4 10-04-2008 20:15:44
Selección Múltiple de Items en un ListView Rolo Varios 6 31-08-2007 21:28:58
Imprimir por seleccion? danytorres Impresión 4 27-11-2006 19:15:59
sacar sólo un subitem de un listview unreal4u Varios 7 02-07-2005 09:34:28
una seleccion YolandaM Impresión 2 04-10-2003 20:11:59


La franja horaria es GMT +2. Ahora son las 17:40:30.


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