一个listview的例子 var LabelRect:TRect; Label1:TLabel; begin LabelRect:=ListView1.Items.Item[0].DisplayRect(drBounds); Label1:=TLabel.Create(ListView1); with Label1 do begin parent:=ListView1; caption:='a link example'; //onclick:=a procedure 这里是你的处理过程,如打开窗口等 cursor:=crHandPoint; font.Color:=clRed;font.charset:=ANSI_CHARSET;font.Size:=10;font.Name:='宋体'; top:=LabelRect.Top+1; left:=LabelRect.Left+ListView1.Columns[0].Width+10; end; end;
最后还少了一句,改正一下,另外你可以把上面的代码放在一个过程中,如一个按纽的点击事件中,具体的根据你需要了 var LabelRect:TRect; Label1:TLabel; begin LabelRect:=ListView1.Items.Item[0].DisplayRect(drBounds); Label1:=TLabel.Create(ListView1); with Label1 do begin parent:=ListView1; caption:='a link example'; //onclick:=a procedure cursor:=crHandPoint; font.Color:=clRed;font.charset:=ANSI_CHARSET;font.Size:=10;font.Name:='宋体'; top:=LabelRect.Top+1; left:=LabelRect.Left+ListView1.Columns[0].Width+2; end; ListView1.Items.Item[0].Data:=Label1; end;
错误如下:Project Project.exe raised exception class EAccessViolation with message 'Access violation at address 00432BCO in module 'Project1.exe'. Read of address 00000004'. Process stopped. Use Step or Run to continue.
[email protected]
var
LabelRect:TRect;
Label1:TLabel;
begin
LabelRect:=ListView1.Items.Item[0].DisplayRect(drBounds);
Label1:=TLabel.Create(ListView1);
with Label1 do
begin
parent:=ListView1;
caption:='a link example';
//onclick:=a procedure 这里是你的处理过程,如打开窗口等
cursor:=crHandPoint;
font.Color:=clRed;font.charset:=ANSI_CHARSET;font.Size:=10;font.Name:='宋体';
top:=LabelRect.Top+1;
left:=LabelRect.Left+ListView1.Columns[0].Width+10;
end;
end;
var
LabelRect:TRect;
Label1:TLabel;
begin
LabelRect:=ListView1.Items.Item[0].DisplayRect(drBounds);
Label1:=TLabel.Create(ListView1);
with Label1 do
begin
parent:=ListView1;
caption:='a link example';
//onclick:=a procedure
cursor:=crHandPoint;
font.Color:=clRed;font.charset:=ANSI_CHARSET;font.Size:=10;font.Name:='宋体';
top:=LabelRect.Top+1;
left:=LabelRect.Left+ListView1.Columns[0].Width+2;
end;
ListView1.Items.Item[0].Data:=Label1;
end;
[email protected]