I think that this behaviour DONT USE "master-detail" technic! NO NO NO
I think that is "better" use "events" of each ListView and find the records in each table, just like this:
implementation
{$R *.fmx}
var UseListViewChangeEvent: boolean = false;
procedure TForm1.FormCreate(Sender: TObject); var LVchildren: TControl; begin // not Scroll visible, BUT working!!! for LVchildren in ListView1.Controls do if LVchildren is TScrollBar then LVchildren.Width := 0; // for LVchildren in ListView2.Controls do if LVchildren is TScrollBar then LVchildren.Width := 0; // // no Accessory visible... ListView1.ItemAppearanceObjects.ItemObjects.Accessory.Visible := false; ListView2.ItemAppearanceObjects.ItemObjects.Accessory.Visible := false; end;
procedure TForm1.FormShow(Sender: TObject); begin UseListViewChangeEvent := true; // ok... you can use this event now! end;
procedure TForm1.ListView1Change(Sender: TObject); begin if not UseListViewChangeEvent then exit; // BindSourceDB2.DataSet.Locate('CUST_NO', BindSourceDB1.DataSet.FieldByName('CUST_NO').AsInteger, []); end;
procedure TForm1.ListView2Change(Sender: TObject); begin if not UseListViewChangeEvent then exit; // BindSourceDB1.DataSet.Locate('CUST_NO', BindSourceDB2.DataSet.FieldByName('CUST_NO').AsInteger, []); end;
end.
此帖子包含附件: 大小:83.5K
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
-- You can use "TStyleBook" to edit the ListView style for changes the colors, and others effects necessary!!!
Ex.: Frame COLOR === Background COLOR to hide separate-line between records!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
procedure TForm1.LoadDataOnListView; // you can to do another way... var LVItem: TListViewItem; begin ListView1.Items.Clear; // fdCategory.First; // // creating a ListView2 "Header + sub-items...." // while not fdCategory.Eof do begin fdProduct.Filtered := false; fdProduct.Filter := 'ID_Category=' + fdCategoryID.AsString; fdProduct.Filtered := true; // fdProduct.First; // if not fdProduct.Eof then begin LVItem := ListView2.Items.Add; LVItem.Text := fdCategoryCategoryName.AsString; LVItem.Purpose := TListItemPurpose.Header; // while not fdProduct.Eof do begin LVItem := ListView2.Items.Add; LVItem.Text := fdProductProductName.AsString; LVItem.Detail := FloatToStrF(fdProductProductPrice.AsCurrency, tfloatformat.ffCurrency, 15, 2); // fdProduct.Next; end; end; // fdCategory.Next; end; // fdProduct.Filtered := false; fdProduct.Filter := ''; fdProduct.First; // fdCategory.First; // while not fdCategory.Eof do begin LVItem := ListView1.Items.Add; LVItem.Text := fdCategoryCategoryName.AsString; LVItem.Tag := fdCategoryID.AsInteger; // fdCategory.Next; end; // fdCategory.First; end;
procedure TForm1.FormShow(Sender: TObject); begin YouCanUseListViewChangeEvent := true; // ... to "OnChange" (ListView1) job! end;
[b] ---> JUST THIS PROCEDURE DO ALL procedure TForm1.ListView1Change(Sender: TObject); begin if not YouCanUseListViewChangeEvent then exit; // for var i: integer := 0 to (ListView2.ItemCount - 1) do if (ListView2.Items[i].Purpose = TListItemPurpose.Header) and { } (ListView2.Items[i].Text = ListView1.Items[ListView1.ItemIndex].Text) then begin ListView2.ItemIndex := i; // Header... ListView2.ItemIndex := (i + 1); // Item... // break; end; end; [/B]
end. //**********//
此帖子包含附件: 大小:74.3K
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
using "SQL" (like FDQuery) is better than my "WHILE Dataset.EOF do ...." procedure!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
... while not fdProduct.Eof do begin LVItem := ListView2.Items.Add; LVItem.Tag := fdProductID_Category.AsInteger; <----- ... // fdProduct.Next; end;
.....
procedure TForm1.ListView2Change(Sender: TObject); begin if not YouCanUseListViewChangeEvent then exit; // for var i: integer := 0 to (ListView1.ItemCount - 1) do if (ListView1.Items[i].Tag = ListView2.Items[ListView2.ItemIndex].Tag) then begin ListView1.ItemIndex := i; <---- select in ListView1 // break; end; end;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3