Click here to Skip to main content
15,923,051 members
Home / Discussions / C#
   

C#

 
QuestionURL's Pin
Gregory Bryant1-Aug-09 11:34
Gregory Bryant1-Aug-09 11:34 
AnswerRe: URL's Pin
Henry Minute1-Aug-09 11:59
Henry Minute1-Aug-09 11:59 
GeneralRe: URL's Pin
Gregory Bryant1-Aug-09 13:04
Gregory Bryant1-Aug-09 13:04 
GeneralRe: URL's Pin
Richard Andrew x641-Aug-09 14:14
professionalRichard Andrew x641-Aug-09 14:14 
GeneralRe: URL's Pin
Gregory Bryant1-Aug-09 15:56
Gregory Bryant1-Aug-09 15:56 
GeneralRe: URL's Pin
Richard Andrew x641-Aug-09 16:05
professionalRichard Andrew x641-Aug-09 16:05 
GeneralRe: URL's Pin
Gregory Bryant1-Aug-09 16:10
Gregory Bryant1-Aug-09 16:10 
GeneralRe: URL's Pin
Gregory Bryant1-Aug-09 16:28
Gregory Bryant1-Aug-09 16:28 
GeneralRe: URL's Pin
Richard Andrew x641-Aug-09 16:32
professionalRichard Andrew x641-Aug-09 16:32 
GeneralRe: URL's Pin
Gregory Bryant1-Aug-09 16:38
Gregory Bryant1-Aug-09 16:38 
QuestionCrystalReport ReportSource not from a file path but a byte array. Possible? Pin
Wendell.S1-Aug-09 11:10
Wendell.S1-Aug-09 11:10 
QuestionPrevent same user to login [modified] Pin
gal0001-Aug-09 10:32
gal0001-Aug-09 10:32 
AnswerRe: Prevent same user to login Pin
Abhijit Jana1-Aug-09 11:00
professionalAbhijit Jana1-Aug-09 11:00 
GeneralRe: Prevent same user to login Pin
Luc Pattyn1-Aug-09 11:25
sitebuilderLuc Pattyn1-Aug-09 11:25 
GeneralRe: Prevent same user to login Pin
Eddy Vluggen1-Aug-09 14:46
professionalEddy Vluggen1-Aug-09 14:46 
GeneralRe: Prevent same user to login Pin
Luc Pattyn1-Aug-09 14:55
sitebuilderLuc Pattyn1-Aug-09 14:55 
GeneralRe: Prevent same user to login Pin
Xmen Real 1-Aug-09 18:05
professional Xmen Real 1-Aug-09 18:05 
QuestionSingleton Pattern - When Use Pin
dataminers1-Aug-09 8:15
dataminers1-Aug-09 8:15 
AnswerRe: Singleton Pattern - When Use Pin
Not Active1-Aug-09 9:12
mentorNot Active1-Aug-09 9:12 
GeneralRe: Singleton Pattern - When Use Pin
dataminers1-Aug-09 10:14
dataminers1-Aug-09 10:14 
QuestionTreeView Recursion Pin
Muammar©1-Aug-09 7:50
Muammar©1-Aug-09 7:50 
AnswerRe: TreeView Recursion Pin
Mike Ellison1-Aug-09 10:47
Mike Ellison1-Aug-09 10:47 
GeneralRe: TreeView Recursion Pin
Muammar©1-Aug-09 12:50
Muammar©1-Aug-09 12:50 
GeneralRe: TreeView Recursion Pin
OriginalGriff1-Aug-09 21:59
mveOriginalGriff1-Aug-09 21:59 
Here's the method I use:
/// <summary>
/// Adds a branch to a TreeView control
/// </summary>
/// <remarks>
/// The Path contains the name of the node to be used in the tree view, for example
/// "General" or "Colours".
/// If the path is qualified with '\' or '/' then it is treated as a hierarchical path
/// and the full path required is generated. For example, if the path was
/// "General\Colors\Pens" the the tree view would display
///      General
///          Colours
///              Pens
/// and any of these branches would select the node.
///
/// The Description can be used for the display of more information.
/// </remarks>
/// <example>
/// AddBranch(tvSelect.Nodes,
///           @"General\Colours",
///           @"Change the colours settings for items",
///           object o);
/// </example>
/// <param name="nc">TreeNodeCollection: TreeView Nodes collection to add to</param>
/// <param name="Path">string: TreeView Hierarchy path to object</param>
/// <param name="Description">string: Plain english description of the object</param>
/// <param name="o">object: object to add to TreeView</param>
public static void AddBranch(TreeNodeCollection nc, string Path, string Description, object o)
    {
    string[] paths = Path.Split('\\', '/'); // Break "General\Font" to "General", "Font" etc.
    TreeNode node;
    foreach (string s in paths)
        {
        if (s == null || s == "")
            {
            // Ignore leading "\", or instances of "\\".
            continue;
            }
        if ((node = FindBranch(nc, s)) == null)
            {
            // Branch does not exist.
            // create it.
            node = new TreeNode();
            node.Name = Description;
            node.Text = s;
            node.Tag = o;
            nc.Add(node);
            }
        // Move down the tree.
        // This allows us to create the sub-branches.
        nc = node.Nodes;
        }
    }

/// <summary>
/// Locates a given Node, returns it if found
/// </summary>
/// <param name="nc">TreeNodeCollection: List of TreeNode items to search</param>
/// <param name="name">string: Name of branch (or leaf) to search for.</param>
/// <returns>Node if found, null if not.</returns>
public static TreeNode FindBranch(TreeNodeCollection nc, string name)
    {
    if ((name != null) && (name != ""))
        {
        foreach (TreeNode n in nc)
            {
            if (n.Text == name)
                {
                return n;
                }
            }
        }
    return null;
    }


Comments make it pretty obvious how to use.

No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.

This message is made of fully recyclable Zeros and Ones

GeneralRe: TreeView Recursion Pin
Muammar©1-Aug-09 23:18
Muammar©1-Aug-09 23:18 

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.