Mega Search
23.2 Million


Sign Up

Make a donation  
How do I keep category panels in the correct order?  
News Group: embarcadero.public.delphi.ide

I have a TCategoryPanelGroup control onto which I have placed a series of TCategoryPanels, each one being numbered from the top cpGroup1...cpGroup10 at the bottom at design time.  Each category panel contains a tree that holds some data from a table, one field has a diplay order that indicates which group it belongs to, say 4 groups, the unused ones are not visible (ie. cpGroup5..cpGroup10 visible := False).  At startup I read the data in and each one is in order and contains the data I expect.  

During run time I add a record to the table and renumber the display order appropriately, eg. adding an entry at position 2 will renumber the display order fields from 1,2,3,4 to 1,3,4,5 with a new entry for 2.  I then make all of the category panels invisible and iterate through a query sorted by display order.  All of the data is placed into the correct category panel....however....the panels themselves are not in order!  Instead of being cpGroup1...cpGroup5 it may be cpGroup1, cpGroup3, cpGroup4, cpGro
up2, cpGroup5, or some other order (but I cannot see a pattern) even though the panels are made visible in the correct order, ie. display order 1 is read first, cpGroup1 is made visible, data is placed into the tree, then display order 2 is processed.

I found something on the net to suggest calculating the top position for each one, however, this does not work as I expected, and I don't see why this should even need to be done.  Is there something else I can do to ensure the panels are always displayed in the correct order?  Can I do something to "simulate" what happens at startup where they are all correct.

I expected this to be fairly simple and designed the code to assume group1 would always be at the top and group2 below it...but they are not.....grrrr.....I am using XE on W7.

Any thoughts?
Trevor

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 30-Nov-2012, at 12:29 AM EST
From: Trevor Hand
 
Re: How do I keep category panels in the correct order?  
News Group: embarcadero.public.delphi.ide
> {quote:title=Trevor Hand wrote:}{quote}
> I have a TCategoryPanelGroup control onto which I have placed a series of TCategoryPanels, each one being numbered from the top cpGroup1...cpGroup10 at the bottom at design time.  Each category panel contains a tree that holds some data from a table, one field has a diplay order that indicates which group it belongs to, say 4 groups, the unused ones are not visible (ie. cpGroup5..cpGroup10 visible := False).  At startup I read the data in and each one is in order and contains the data I expect.  
> 
> During run time I add a record to the table and renumber the display order appropriately, eg. adding an entry at position 2 will renumber the display order fields from 1,2,3,4 to 1,3,4,5 with a new entry for 2.  I then make all of the category panels invisible and iterate through a query sorted by display order.  All of the data is placed into the correct category panel....however....the panels themselves are not in order!  Instead of being cpGroup1...cpGroup5 it may be cpGroup1, cpGroup3, cpGroup4, cpG
roup2, cpGroup5, or some other order (but I cannot see a pattern) even though the panels are made visible in the correct order, ie. display order 1 is read first, cpGroup1 is made visible, data is placed into the tree, then display order 2 is processed.
> 
> I found something on the net to suggest calculating the top position for each one, however, this does not work as I expected, and I don't see why this should even need to be done.  Is there something else I can do to ensure the panels are always displayed in the correct order?  Can I do something to "simulate" what happens at startup where they are all correct.
> 
> I expected this to be fairly simple and designed the code to assume group1 would always be at the top and group2 below it...but they are not.....grrrr.....I am using XE on W7.
> 
> Any thoughts?

You should make panels invisible from bottom to top, and then make them visible
in top to bottom order. That should work.

Dalija Prasnikar

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 30-Nov-2012, at 8:16 AM EST
From: Dalija Prasnikar
 
Re: How do I keep category panels in the correct order?  
News Group: embarcadero.public.delphi.ide
This worked a treat!  I was able to delete about 20 lines of code in the startup too, just a brief comment in the code to explain why I am iterating in the reverse order, just in case I forget or someone else has to change it some time, othewise it may be tempting to "tidy it up" and use a simple for loop.


> {quote:title=Dalija Prasnikar wrote:}{quote}
> > {quote:title=Trevor Hand wrote:}{quote}
> > I have a TCategoryPanelGroup control onto which I have placed a series of TCategoryPanels, each one being numbered from the top cpGroup1...cpGroup10 at the bottom at design time.  Each category panel contains a tree that holds some data from a table, one field has a diplay order that indicates which group it belongs to, say 4 groups, the unused ones are not visible (ie. cpGroup5..cpGroup10 visible := False).  At startup I read the data in and each one is in order and contains the data I expect.  
> > 
> > During run time I add a record to the table and renumber the display order appropriately, eg. adding an entry at position 2 will renumber the display order fields from 1,2,3,4 to 1,3,4,5 with a new entry for 2.  I then make all of the category panels invisible and iterate through a query sorted by display order.  All of the data is placed into the correct category panel....however....the panels themselves are not in order!  Instead of being cpGroup1...cpGroup5 it may be cpGroup1, cpGroup3, cpGroup4, c
pGroup2, cpGroup5, or some other order (but I cannot see a pattern) even though the panels are made visible in the correct order, ie. display order 1 is read first, cpGroup1 is made visible, data is placed into the tree, then display order 2 is processed.
> > 
> > I found something on the net to suggest calculating the top position for each one, however, this does not work as I expected, and I don't see why this should even need to be done.  Is there something else I can do to ensure the panels are always displayed in the correct order?  Can I do something to "simulate" what happens at startup where they are all correct.
> > 
> > I expected this to be fairly simple and designed the code to assume group1 would always be at the top and group2 below it...but they are not.....grrrr.....I am using XE on W7.
> > 
> > Any thoughts?
> 
> You should make panels invisible from bottom to top, and then make them visible
> in top to bottom order. That should work.
> 
> Dalija Prasnikar

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 2-Dec-2012, at 8:33 PM EST
From: Trevor Hand
 
Re: How do I keep category panels in the correct order?  
News Group: embarcadero.public.delphi.ide
I found I was doing something else that may have caused the problem too, I was setting visible to true each time I was adding an entry to each tree, but the entries were not in order.  But I will have a look at this too, I will try loading all of the messages and then iterating in order from the top to bottom to make the requried ones visible.  I think setting the visible property seems to move them to the bottom of the group, which is not an expected response.

I will let you know if this helps.
Trevor

 
> {quote:title=Dalija Prasnikar wrote:}{quote}
> > {quote:title=Trevor Hand wrote:}{quote}
> > I have a TCategoryPanelGroup control onto which I have placed a series of TCategoryPanels, each one being numbered from the top cpGroup1...cpGroup10 at the bottom at design time.  Each category panel contains a tree that holds some data from a table, one field has a diplay order that indicates which group it belongs to, say 4 groups, the unused ones are not visible (ie. cpGroup5..cpGroup10 visible := False).  At startup I read the data in and each one is in order and contains the data I expect.  
> > 
> > During run time I add a record to the table and renumber the display order appropriately, eg. adding an entry at position 2 will renumber the display order fields from 1,2,3,4 to 1,3,4,5 with a new entry for 2.  I then make all of the category panels invisible and iterate through a query sorted by display order.  All of the data is placed into the correct category panel....however....the panels themselves are not in order!  Instead of being cpGroup1...cpGroup5 it may be cpGroup1, cpGroup3, cpGroup4, c
pGroup2, cpGroup5, or some other order (but I cannot see a pattern) even though the panels are made visible in the correct order, ie. display order 1 is read first, cpGroup1 is made visible, data is placed into the tree, then display order 2 is processed.
> > 
> > I found something on the net to suggest calculating the top position for each one, however, this does not work as I expected, and I don't see why this should even need to be done.  Is there something else I can do to ensure the panels are always displayed in the correct order?  Can I do something to "simulate" what happens at startup where they are all correct.
> > 
> > I expected this to be fairly simple and designed the code to assume group1 would always be at the top and group2 below it...but they are not.....grrrr.....I am using XE on W7.
> > 
> > Any thoughts?
> 
> You should make panels invisible from bottom to top, and then make them visible
> in top to bottom order. That should work.
> 
> Dalija Prasnikar

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 2-Dec-2012, at 6:32 PM EST
From: Trevor Hand
 
Re: How do I keep category panels in the correct order?  
News Group: embarcadero.public.delphi.ide
To be honest.....I forgot about "downto" as I was more focussed on getting the stupid thing working.... :-(  I am now though :-)


> {quote:title=Robert Small wrote:}{quote}
> Trevor Hand <> wrote:
> 
> >This worked a treat!  I was able to delete about 20 lines of code in the startup too, just a brief comment in the code to explain why I am iterating in the reverse order, just in case I forget or someone else has to change it some time, othewise it may be tempting to "tidy it up" and use a simple for loop.
> >
> 
> Probably a silly question, but why aren't you using a "simple for
> loop" 
> 
> for i := TCategoryPanelGroup.Count - 1 downto 0 do stuff;
> -- 
> Bob Small

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 7-Dec-2012, at 6:34 PM EST
From: Trevor Hand