Changeset 12235


Ignore:
Timestamp:
03/23/15 10:19:35 (5 years ago)
Author:
pfleck
Message:

#2025 First result is automatically selected when typing in search box.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/NewItemDialog/HeuristicLab.Optimizer/3.3/NewItemDialog.cs

    r12234 r12235  
    196196        currentSearchString = searchString;
    197197
    198         // if there is just one type node left, select by default
    199         if (typesTreeView.Nodes.Count == 1) {
    200           if (typesTreeView.Nodes[0].Nodes.Count == 1) {
    201             typesTreeView.SelectedNode = typesTreeView.Nodes[0].Nodes[0];
    202           }
     198        // select first item
     199        if (selectedType == null) {
     200          var firstNode = FirstVisibleNode;
     201          while (firstNode != null && !(firstNode.Tag is Type))
     202            firstNode = firstNode.NextVisibleNode;
     203          if (firstNode != null)
     204            typesTreeView.SelectedNode = firstNode;
    203205        }
    204206
     
    406408    private TreeNode FirstVisibleNode {
    407409      get {
    408         return typesTreeView.Nodes[0];
     410        return typesTreeView.Nodes.Count > 0 ? typesTreeView.Nodes[0] : null;
    409411      }
    410412    }
     
    412414      get {
    413415        var node = FirstVisibleNode;
    414         while (node.NextVisibleNode != null) node = node.NextVisibleNode;
     416        while (node != null && node.NextVisibleNode != null) node = node.NextVisibleNode;
    415417        return node;
    416418      }
Note: See TracChangeset for help on using the changeset viewer.