EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Open TInspectorList categories at run-time

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Form Designer
View previous topic :: View next topic  
Author Message
aecspades



Joined: 04 Dec 2006
Posts: 14

PostPosted: Tue Jan 09, 2007 1:33 pm    Post subject: Open TInspectorList categories at run-time Reply with quote

Is there a way to programmatically ‘open’ a property category at run-time in a TInspectorList component? For example, using EC_NO_BPL;NEWNEWDESIGNER;EC_DSN_REG;EC_REG conditionals I have code that adds the most-used properties to a category called ‘Common’:

RegisterPropertiesInCategory('Common', ['Active', 'Align', 'Caption', 'Connection', 'DataSet', 'DataSource', 'Font', 'Items','Lines', 'Name', 'Picture', 'Text']);

In the TInspectorList component, I have set the ByCategories property to true. Right now, when I drop a new component on the form all of the categories correctly show, but they are all collapsed. What I’d like is some way to open the ‘Common’ category (it should always be there because of the Name property) either through a method call or maybe a ‘DefaultCategoryName’ property that could be added to the TInspectorList component (which would, by default, open that category name when present).

I’ve looked through the documentation and can’t see anything similar. Please let me know if it is possible or if you would consider this as a possible enhancement.
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Wed Jan 10, 2007 7:47 am    Post subject: Reply with quote

Add to public of TCustomInspectorList:
Code:
property Nodes: TPropertyNodes read FNodes;

After that you may use next code to expand 'Common' category:
Code:
  with InspectorList1 do
    for i := 0 to Nodes.Count - 1 do
      if (Nodes[i] is TCategoryNode) and (Nodes[i].Name = 'Common') then
        Nodes[i].Expand;


Michael.
Back to top
View user's profile Send private message Send e-mail
aecspades



Joined: 04 Dec 2006
Posts: 14

PostPosted: Wed Jan 10, 2007 1:52 pm    Post subject: Open TInspectorList categories at run-time Reply with quote

Works great! I added the code to the OnPropListUpdated event:

Code:
with InspectorList1 do
  // Nodes seems to be null when the form gets closed...
  if Nodes<>nil then
    for i := 0 to Nodes.Count - 1 do
      if (Nodes[i] is TCategoryNode) and (Nodes[i].Name = 'Common') then
        begin
          Nodes[i].Expand;
          exit;
        end;


I had to deal with a null Node when the form was closed or I got an Access Violation. If there is a better place to put the code (I'm using a modified version of the FormWithParent demo) or if that is the wrong way to deal with the null node, please let me know. Otherwise, thank you very much.

P.S. please consider adding the Nodes property as a future enhancment idea so I don't have to change the code every time a new version is released. Thanks again.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Form Designer All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group