ListView jak edytować tak jak w DBGrid

0

Pytanie jak najbardziej banalne ale jakoś nie znalazłem na to rozwiązania.
Kiedy w ListView RowSelect=false oraz ReadOlny=false mamy możliwość edycji 1 kolumny a jak zrobić aby można było edytować np. 3 lub 4 kolumnę w jakiejś tam lini tak jak np. w DBGrid???

Nie chodzi mi o edycje z poziomu kodu programu.

0

Myślę, że to Ci może pomóc ;)

procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  liTemp: TListItem;
  sSub: string;
begin
  liTemp := ListView1.GetItemAt(X,Y);
  if liTemp <> nil then
    xPos := x;
end;

procedure TForm1.ListView1DblClick(Sender: TObject);
var
  i,xs, xe, iCol: Integer;
  bFound: Boolean;
  ADefault: string;
begin
  if ListView1.Selected = nil then Exit;
  // default
  xs := 0;
  xe := 0;
  iCol := 0;
  bFound := False;
  for i := 0 to Pred(ListView1.Columns.Count) do
  begin
    xe := xs + ListView1.Columns[i].Width;
    if (xe > xPos) and (xs < xPos) then
    begin
      bFound := True;
      break
    end
    else
      Inc(iCol);
    xs := xe;
  end;
  if bFound then
  begin
    if iCol = 0 then
      ListView1.Selected.Caption :=
        InputBox('Change Value',
                 'Enter new value',
                 Trim(ListView1.Selected.Caption))
    else
      ListView1.Selected.SubItems[iCol-1] :=
        InputBox('Change Value',
                 'Enter new value',
                 Trim(ListView1.Selected.SubItems[iCol-1]));
  end;
end;

end.

1 użytkowników online, w tym zalogowanych: 0, gości: 1