Searching in Trees

In conzept 16 version 5.7.04, we added a search function to the Designer’s trees. We will now make this available to conzept 16 developers as well, so that the search function can be used within their own applications—that is, at runtime. This article explains how to use the search function.


Complex tree structures can quickly become confusing. Take, for example, a tree that represents a directory structure. It contains multiple folders, subfolders, and files. If you’re looking for a specific file, this can sometimes result in a very lengthy search process. For this reason, the TreeView object has been enhanced with a search feature.

Use search
Suche im TreeView

Nothing could be easier! To use the search function, simply set the new property wpSearchEnabled of the TreeView object to true. The search is performed based on the display text of the nodes in the tree. By default, the following keys are used for this:

  • Ctrl + F – Starts the search
  • F3 – Find the next match
  • Shift + F3 – Find the previous match

The keys and keyboard shortcuts are defined in the Properties and can be customized.

In addition, the new command WinTreeNodeSearch() allows you to search for a node procedurally.

Advanced search options

The search iterates through all nodes in the TreeView and compares the search expression with the node’s wpCaption property, or optionally the wpCustom property. The developer can decide how the comparison is performed. In addition to a wildcard search, regular expressions and a term-based search are also available.

In addition, it is possible to implement custom search algorithms. To this end, the TreeView object has been extended with the EvtNodeSearch event. This event is triggered for every node that is processed during the search. Here, for example, the internal text associated with a node could be searched for the search term. If the term is found, the corresponding node can be marked as a match. The search ends as soon as a node is identified as a match, the tree has been traversed completely, or the user cancels the search.

sub EvtNodeSearch
(
  aEvt                  : event;            // Event
  aNode                 : handle;           // Node
  aPattern              : alpha;            // Search term
  aFlags                : int;              // Search options
  aAction               : int;              // [in, out] Action
)
: logic;                                    // Continue searching?
{
  // Remember the start time of the search
  if (gSearchStart = 0)
    gSearchStart # SysTics();

  // If the text associated with the node contains the search term
  // Mark node as a match
  if (aNode->Node.TextContains(aPattern))
    aAction # _WinTreeNodeSearchFound;

  if (aAction & _WinTreeNodeSearchFound != 0)
    gSearchStart # 0;

  // Cancel search after 30 seconds
  if (SysTics() - gSearchStart > 30000)
  {
    gSearchStart # 0;
    return (false);
  }

  return (true);
}

Klicken Sie hier, um die Nutzungsbedingungen für unseren Blog zu lesen.

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!

Requests, questions or feedback are welcome:

Terms of use of the comment function in the blog

1. General information

Vectorsoft AG (‘Provider’) provides a public blog for Internet users (‘Users’) on the vectorsoft.de website. The public blog is intended for the exchange of information and ideas. Users who participate with contributions and comments undertake to comply with the blog terms of use and are responsible for the accuracy, appropriateness and freedom from legal infringements of their contributions. By using the comment function in our blog, you accept these terms of use.

2. Netiquette

We ask you to refrain from personal attacks and provocations based on other opinions. Please argue objectively and maintain a constructive discussion culture. Your comment should always be related to the topic in question in order to avoid digressions into other topics. Posting the same comment or several similar comments more than once is not permitted.

3. Prohibition of illegal content

By submitting your comment, you confirm that you are not violating any copyrights or other rights of third parties. Inciting, racist statements, instructions for criminal offences and their glorification, depictions of violence, pornographic content and statements that violate personal rights are prohibited.

4. No advertising

The use of the comment function is not permitted for commercial or party-political purposes. Advertising contributions of any kind will be deleted immediately.

5. Details of the name

When entering your name, pay attention to the principles mentioned above.

6. Source references

If you intend to publish quotes or contributions from third parties, please indicate the respective sources and explain how they relate to the blog post.

7. Violation of the terms of use

Posts that violate this policy will be deleted immediately. If you notice any violations yourself, please send us the link to the comment in question by e-mail to . We expressly point out that we will exclude individual users in the event of repeated or serious violations of these terms of use.

As of: Sept. 2024

Get your Trial Version now!

Test yeet free of charge

IHRE EVALUIERUNGSLIZENZ - JETZT ANFORDERN!

TESTEN SIE DIE CONZEPT 16 VOLLVERSION - UNVERBINDLICH und KOSTENFREI

Subscribe to our newsletter

Anrede*
     
Zustimmung zur Datenverarbeitung gem. DSGVO*



WordPress Cookie Notice by Real Cookie Banner