• 6 odgovora
  • 2.731 pregleda
Editing subitems u listview 18.02.2011. u 17:38 · pre 190 meseci #1
Probao sa
tab.ItemFocused.EditCaption;
ali samo prvi red edituje,
kako ostale redove editovati ?
Re: Editing subitems u listview 18.02.2011. u 20:12 · pre 190 meseci #3
Pa ne tako, nego npr. dvoklik na red i da se iz tabele može direktno izmenuti Subitems-i na kojem je kliknuto.

Ovo što sam napisao u prvom postu omogućava izmenu samo 1 kolone=Caption a treba mi da tako mogu i sa ostalim Subitems-ima.
Re: Editing subitems u listview 21.02.2011. u 08:35 · pre 190 meseci #4
Standardni ListView nema mogućnost editovanja SubItema već samo Captiona. Ako ti to baš treba, preporučujem da pređeš na VirtualTreeView. Trebaće ti malo vremena da ukapiraš kako funkcioniše, ali nakon toga nećeš prestati da je koristiš. Pored toga što je edit moguć u svim kolonama, komponenta ti daje punu kontrolu nad time šta i kako korisnik može da radi, kao i mogućnost da zameniš običan edit sa nekom drugom kontrolom (ComboBox, DateTimePicker, ...).
Potpis
"There is a theory which states that if ever anybody discovers exactly what the
Universe is for and why it is here, it will instantly disappear and be replaced by
something even more bizarre and inexplicable. There is another theory which states
that this has already happened."
-- Douglas Adams
Re: Editing subitems u listview 21.02.2011. u 09:26 · pre 190 meseci #5
Hvala na savetu,
ListView mi je u ovom programu neka pomoćna tabelica pa sam mislio ubaciti mogućnost uzmene podataka, ali kada ne može ko ga šiša, neću sve menjati zbog toga.

Još jednom hvala.
Re: Editing subitems u listview 21.02.2011. u 13:46 · pre 190 meseci #6
VirtualTreeView je dobra preporuka... ali pošto ćeš zadržati ListView evo kako može:

Code:

procedure TNekaForma.ListView1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  ListItem: TListItem;
  Column, Len: Integer;
  Edit: TEdit;
  i: Integer;
begin
  ListItem := ListView1.GetItemAt(X, Y);
  if not Assigned(ListItem) then
    Exit;

  Column := 0;
  Len := X;

  while Len > ListView1.Columns[Column].Width do
  begin
    Len := Len - ListView1.Columns[Column].Width;
    Inc(Column);
  end;

  Dec(Column);

  Edit := TEdit.Create(ListView1);
  try
    Edit.Parent := ListView1;
    Edit.Left := X;
    Edit.Top := y;

    if (Column > -1)and(Column < ListItem.SubItems.Count) then
      Edit.Text := ListItem.SubItems[Column]
    else
    if (Column = ListItem.SubItems.Count)and(Column < ListView1.Columns.Count) then
      Edit.Text := '';

    EndEdit := False;
    //Edit.OnKeyDown := Edit1KeyDown;

    Edit.SetFocus;
    i := 0;
    while i < 100 do
    begin
      Application.ProcessMessages;
      if EndEdit then
        break;
      Inc(i);
      sleep(100);
    end;

    if (Column > -1)and(Column < ListItem.SubItems.Count) then
      ListItem.SubItems[Column] := Edit.Text
    else
    if (Column = ListItem.SubItems.Count)and(Column < ListView1.Columns.Count) then
      ListItem.SubItems.Add(Edit.Text);

  finally
    Edit.Free;
  end;  
end;


Ovo, naravno, ima nedostataka tako da bi morao da je doradiš. U Edit1KeyDown može da bude:

Code:

  if Key = VK_RETURN then
    EndEdit := True;

Re: Editing subitems u listview 21.02.2011. u 19:15 · pre 190 meseci #7
Probao sam i odlično je,
EndEdit treba staviti kao "boolean"
ubacio sam Edit1KeyDown i radi OK.


[Ovu poruku je menjao Brkic dana 23.02.2011. u 14:01 GMT+1]
Prijavite se da biste odgovorili u ovoj temi.PrijavaRegistracija

Premeštanje teme