Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

TElXTree: After reversing the order, make the Focused item visible

Assume there are 50 items at Level 0 (Children of the root).
Item 0 is the FocusedItem.

After reversing order, I do the following to make the focused item visible, only it doesn't work.

      ItemFocused := Items.Item[FocusedIndex];  // This line works to make the ItemFocused the same as before reversing the order.

      ItemFocused.MakeVisible();              // Tried this: doesn't work.
      TopIndex := ItemFocused.VisIndex;   // Tried this: doesn't work.

What is to be done, please?

Thanks.
Raymond

Comments

  • 4 Comments sorted by Votes Date Added
  • Posts: 0 Accepted Answer Vote Up0Vote Down
    Sorry, I'm not sure how to reproduce. 
    What exactly does your procedure of reversing order?
    MakeVisible and TopIndex works as expected. 

    Sample project with problem clearly reproduced would be of great help here.



  • I have an improvement.

    If the ParentItem points to the Root, then the following code works when there is a focused item prior to reversing the order of the items..

        TempItem := ParentItem.GetLastChild();

        for i := 0 to Pred(ParentItem.Count) - 1 do
        begin
          TempItem.Index := i;

          TempItem := ParentItem.GetLastChild();
        end;

        if ItemFocused <> nil then
        begin
          TopIndex := ItemFocused.Index;
        end;

    However, although for children of an item, (i.e. when ParentItem <> Root) reversing the order of these children keeps the correct item focused, the focused item does not appear visible when setting the TopIndex as above.

    Raymond
  • I couldn't reproduce it in a demo, and when I tried it again in my app it works as expected. Strange.

    No need to pursue this. Sorry.

    Raymond

Sign In or Register to comment.