Click here to Skip to main content
14,869,731 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: search or filter treenode display based on text input from user Pin
Richard MacCutchan5-Sep-14 21:08
mveRichard MacCutchan5-Sep-14 21:08 
GeneralRe: search or filter treenode display based on text input from user Pin
Member 110597996-Sep-14 4:09
MemberMember 110597996-Sep-14 4:09 
GeneralRe: search or filter treenode display based on text input from user Pin
Richard MacCutchan6-Sep-14 5:02
mveRichard MacCutchan6-Sep-14 5:02 
GeneralRe: search or filter treenode display based on text input from user Pin
Member 110597998-Sep-14 4:13
MemberMember 110597998-Sep-14 4:13 
GeneralRe: search or filter treenode display based on text input from user Pin
Richard MacCutchan8-Sep-14 5:01
mveRichard MacCutchan8-Sep-14 5:01 
AnswerRe: search or filter treenode display based on text input from user Pin
Eddy Vluggen5-Sep-14 2:57
professionalEddy Vluggen5-Sep-14 2:57 
GeneralRe: search or filter treenode display based on text input from user Pin
Member 110597995-Sep-14 10:47
MemberMember 110597995-Sep-14 10:47 
AnswerRe: search or filter treenode display based on text input from user Pin
Eddy Vluggen8-Sep-14 8:35
professionalEddy Vluggen8-Sep-14 8:35 
Member 11059799 wrote:
Not only is there nothing close but nothing near the planet
..there's quite some examples out there on searching, also including WinForm-treeviews. Like I already said, we don't have examples on each scenario. Filtering would be harder to implement than searching; searching a single item and highlighting it would be a lot easier to start with.
  1. Nodes.Find[^]
  2. Looping all nodes yourself (recursively!) and checking it (will be harder if the tree lazyloads, and should ideally be done on the datasource, not the tree itself)


Member 11059799 wrote:
In any event it doesn't look like it contains an example of user text input to
scroll the Tree display.
"Finding" an item in a tree requires a textbox for a search-term, and invoking the Find method. Highlighting that node should bring it into view.

--edit;
Simplest example I could come up with is given below. Do mind the difference between a node-key and its caption. Keynames should be unique, captions don't have to be. Anyting with more flexibility requires more coding.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

static class Program
{
    static void Main()
    {
        using (var f = new Form())
        {
            var tb = new TextBox() { Dock = DockStyle.Top };
            var tv = new TreeView() { Dock = DockStyle.Fill };
            f.Controls.AddRange(new Control[] { tv, tb });

            tv.Nodes.Add("one", "one").Nodes.Add("two", "two");
            tv.Nodes.Add("three", "tree").Nodes.Add("nine", "nine");
            tv.Nodes.Add("tree", "three").Nodes.Add("oak", "oak");

            tb.KeyDown += (o, a) =>
                {
                    a.Handled = a.KeyCode == Keys.Return;
                    if (a.Handled)
                    {
                        TreeNode[] foundNodes = tv.Nodes.Find(tb.Text, true);
                        if (foundNodes.Length > 0)
                        {
                            tv.SelectedNode = foundNodes[0];
                            tv.Focus();
                        }
                    }
                };
            f.ShowDialog();
        }
    }
}

Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]


modified 8-Sep-14 14:54pm.

GeneralRe: search or filter treenode display based on text input from user Pin
Eric P Schneider28-Jan-19 11:03
MemberEric P Schneider28-Jan-19 11:03 
QuestionClosing a dropdown box on a toolstrip item Pin
Member 980468925-Aug-14 6:42
MemberMember 980468925-Aug-14 6:42 
AnswerRe: Closing a dropdown box on a toolstrip item Pin
Ravi Bhavnani25-Aug-14 8:47
professionalRavi Bhavnani25-Aug-14 8:47 
GeneralRe: Closing a dropdown box on a toolstrip item Pin
Member 980468927-Aug-14 5:02
MemberMember 980468927-Aug-14 5:02 
GeneralRe: Closing a dropdown box on a toolstrip item Pin
Member 980468927-Aug-14 5:09
MemberMember 980468927-Aug-14 5:09 
GeneralRe: Closing a dropdown box on a toolstrip item Pin
Ravi Bhavnani27-Aug-14 5:43
professionalRavi Bhavnani27-Aug-14 5:43 
AnswerRe: Closing a dropdown box on a toolstrip item Pin
xstoneheartx25-Dec-14 13:34
Memberxstoneheartx25-Dec-14 13:34 
QuestionC# Error Config file Pin
Member 856781222-Aug-14 20:55
MemberMember 856781222-Aug-14 20:55 
AnswerRe: C# Error Config file Pin
Richard MacCutchan22-Aug-14 21:13
mveRichard MacCutchan22-Aug-14 21:13 
GeneralRe: C# Error Config file Pin
Member 856781222-Aug-14 22:38
MemberMember 856781222-Aug-14 22:38 
GeneralRe: C# Error Config file Pin
Richard MacCutchan23-Aug-14 0:14
mveRichard MacCutchan23-Aug-14 0:14 
GeneralRe: C# Error Config file Pin
Member 856781223-Aug-14 4:19
MemberMember 856781223-Aug-14 4:19 
GeneralRe: C# Error Config file Pin
Richard MacCutchan23-Aug-14 4:49
mveRichard MacCutchan23-Aug-14 4:49 
GeneralRe: C# Error Config file Pin
Member 856781225-Aug-14 22:58
MemberMember 856781225-Aug-14 22:58 
Questionhow to disable windows form hide animation? Pin
neodeaths30-Jul-14 23:30
Memberneodeaths30-Jul-14 23:30 
AnswerRe: how to disable windows form hide animation? Pin
Eddy Vluggen11-Aug-14 7:58
professionalEddy Vluggen11-Aug-14 7:58 
AnswerRe: how to disable windows form hide animation? Pin
xstoneheartx25-Dec-14 14:15
Memberxstoneheartx25-Dec-14 14:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.