Registriert seit: 29. Mai 2002
37.621 Beiträge
Delphi 2006 Professional
|
AW: Listview und Zeile und Spalte einer Zelle
13. Feb 2011, 23:46
Habe es hinbekommen.
Einzelnes Feld:
Delphi-Quellcode:
procedure TfrmMain.lvCSVFileMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbRight then
begin
FX := X;
FY := Y;
FPopupMenuListItem := lvCSVFile.GetItemAt(X, Y);
end;
end;
procedure TfrmMain.GetSubItemFromPoint(X, Y: Integer; var SubItem: Integer);
var
hti: TLVHitTestInfo;
begin
hti.pt := Point(X, Y);
SubItem := ListView_SubItemHitTest(lvCSVFile.Handle, @hti);
if SubItem > 0 then
begin
FPopupMenuListItem := lvCSVFile.Items[SubItem];
SubItem := hti.iSubItem;
end
else
FPopupMenuListItem := nil;
end;
procedure TfrmMain.pmCopyFieldClick(Sender: TObject);
var
SubItem: Integer;
begin
GetSubItemFromPoint(FX, FY, SubItem);
if Assigned(FPopupMenuListItem) then
begin
if SubItem > 0 then
Clipboard.AsText := FPopupMenuListItem.SubItems[SubItem-1];
end;
end;
Ganze Zeile:
Delphi-Quellcode:
procedure TfrmMain.pmCopyRowClick(Sender: TObject);
var
s: AnsiString;
i: Integer;
begin
if Assigned(FPopupMenuListItem) then
begin
for i := 0 to FPopupMenuListItem.SubItems.Count - 1 do
begin
s := s + FPopupMenuListItem.SubItems[i] + FDelimiter;
end;
Setlength(s, Length(s) - 1);
ClipBoard.AsText := s;
end;
end;
Michael Ein Teil meines Codes würde euch verunsichern.
|
|
Zitat
|