Hi all!

Hi all! 

I'm using code like this, since Delphi XE3:

procedure TEnterprisesController.RefreshTreeView_EnterprisesList;
{Clear all data in the view and reload it from database }
{! I M P O R T A N T  !   This method don't executes the query. It spend the query is open previously.}
var EnterpriseItem :TEnterpriseItem;
begin
   FViewList.TreeView.BeginUpdate;
   try
      FViewList.TreeView.Clear;
      FViewList.TreeView.ItemHeight := 42;
      FModel.Refresh;
      while not FModel.EOF do begin
         EnterpriseItem := FModel.GetCurrent;
         InsertTreeViewItem_EnterpriseList(EnterpriseItem);
         FModel.Next;
      end;
   finally
      FViewList.TreeView.EndUpdate;
   end;
end;

procedure TEnterprisesController.InsertTreeViewItem_EnterpriseList(aItem: TEnterpriseItem);
var TreeNode :TTreeViewItem;
begin
   TreeNode := TTreeViewItem.Create(nil);
   TreeNode.Parent    := FViewList.TreeView;
   TreeNode.TagObject := aItem;
   TreeNode.Text := aItem.CD_ENTERPRISE.AsString;
   { this code set event - when we need to setup item }
   TreeNode.OnApplyStyleLookup := DoApplyStyleTreeNodes;
   { this set our style to new item }
   TreeNode.StyleLookup := 'EnterpriseStyle';
end;

procedure TEnterprisesController.DoApplyStyleTreeNodes(Sender: TObject);
var TreeNode :TTreeViewItem;
    Item     :TEnterpriseItem;
begin
   TreeNode := TTreeViewItem(Sender);
   Item     := TEnterpriseItem(TreeNode.TagObject);
   { create thumbnail }
   TreeNode.Text := Item.CD_ENTERPRISE.AsString;
   TreeNode.StylesData['textCD_ENTERPRISE'] := Item.CD_ENTERPRISE.AsString;
   TreeNode.StylesData['textDS_ENTERPRISE'] := Item.DS_ENTERPRISE.AsString;
   TreeNode.StylesData['textAPPLICATION'  ] := Item.APPLICATION.AsString;
   if Item.CLOSED.AsString  = 'Y' then
      TreeNode.StylesData['textCLOSED'] := 'Si'
   else
      TreeNode.StylesData['textCLOSED'] := 'No';

   TreeNode.StylesData['BtnOrderByCodigo.Text'     ] := '';
   TreeNode.StylesData['BtnOrderByDescripcion.Text'] := '';

   //TreeNode.StylesData['BtnOrderByCodigo.OnClick'     ] := TValue.From(OnClick_OrderByCodigo);
   //TreeNode.StylesData['BtnOrderByDescripcion.OnClick'] := TValue.From(OnClick_OrderByDescripcion);


   TreeNode.StylesData['EffectCodigo.Enabled'     ] := False;
   TreeNode.StylesData['EffectDescripcion.Enabled'] := False;

   if FModel.OrderBy.FindField('CD_ENTERPRISE') <> nil then begin
      TreeNode.StylesData['EffectCodigo.Enabled'] := True;
   end else
   if FModel.OrderBy.FindField('DS_ENTERPRISE') <> nil then begin
      TreeNode.StylesData['EffectDescripcion.Enabled'] := True;
   end;
end;

Now I just migrate to Delphi XE10 and in all the views, the code don't work. The TTreeViewNodes appear with no style applied. 

Help!   Please. I use a lot of Treeviews. I have a great problem.

What's changed from XE8.1 to XE10?

I can't find the difference!

Comments

  1. Thanks Paul. This seems to be very near of the problem, but... I have a the problem with TTreeView and TTreeViewItem.  Not ListView and ListViewItem...

    And, please, any one have a urgent solution. I'm blocked!   ;)

    ReplyDelete

Post a Comment