Click here to Skip to main content
15,914,225 members
Home / Discussions / C#
   

C#

 
AnswerRe: [HELP] Plotting readings on graph dynamically Pin
OriginalGriff17-Feb-10 23:19
mveOriginalGriff17-Feb-10 23:19 
QuestionDrawing text along an elliptic line in GDI Pin
Berlus17-Feb-10 20:40
Berlus17-Feb-10 20:40 
AnswerRe: Drawing text along an elliptic line in GDI Pin
OriginalGriff18-Feb-10 0:19
mveOriginalGriff18-Feb-10 0:19 
QuestionThreads issue Pin
HideIvy17-Feb-10 20:18
HideIvy17-Feb-10 20:18 
AnswerRe: Threads issue Pin
Calla17-Feb-10 20:51
Calla17-Feb-10 20:51 
AnswerRe: Threads issue Pin
Mirko198017-Feb-10 21:52
Mirko198017-Feb-10 21:52 
AnswerRe: Threads issue Pin
Nicholas Butler18-Feb-10 0:25
sitebuilderNicholas Butler18-Feb-10 0:25 
QuestionRe: Threads issue Pin
harold aptroot18-Feb-10 0:48
harold aptroot18-Feb-10 0:48 
AnswerRe: Threads issue Pin
David Skelly18-Feb-10 3:03
David Skelly18-Feb-10 3:03 
AnswerRe: Threads issue Pin
HideIvy18-Feb-10 22:28
HideIvy18-Feb-10 22:28 
Questiontreenodecollection nodes not working as expected with created class [SOLVED] Pin
tonyonlinux17-Feb-10 20:07
tonyonlinux17-Feb-10 20:07 
AnswerRe: treenodecollection nodes not working as expected with created class Pin
Dan Mos17-Feb-10 20:28
Dan Mos17-Feb-10 20:28 
GeneralRe: treenodecollection nodes not working as expected with created class [SOLVED] Pin
tonyonlinux18-Feb-10 1:07
tonyonlinux18-Feb-10 1:07 
GeneralRe: treenodecollection nodes not working as expected with created class Pin
tonyonlinux18-Feb-10 1:31
tonyonlinux18-Feb-10 1:31 
GeneralRe: treenodecollection nodes not working as expected with created class Pin
Dan Mos18-Feb-10 2:40
Dan Mos18-Feb-10 2:40 
GeneralRe: treenodecollection nodes not working as expected with created class Pin
tonyonlinux18-Feb-10 6:43
tonyonlinux18-Feb-10 6:43 
GeneralRe: treenodecollection nodes not working as expected with created class Pin
Dan Mos18-Feb-10 10:03
Dan Mos18-Feb-10 10:03 
GeneralRe: treenodecollection nodes not working as expected with created class Pin
tonyonlinux18-Feb-10 13:18
tonyonlinux18-Feb-10 13:18 
here is what I've come up with so far. 208 nodes get put into the array i checked that in the debugger but i get an exception each time it finds a instance where the node is the same. in example
says can not add or insert the item 'tbone,eater' in more than one place.

here is what i'm using in my main form
private void Filter_combo_SelectedIndexChanged(object sender, EventArgs e)
       {
           /* Populate the tree based on whatever the user selects to filter by
            * for example if they click on keywords then only show the keywords
            */

           string filter = Filter_combo.Text;





           using (var db = new mombooksDataContext(Properties.Settings.Default.BooksConnectionString2))
           {

               TreeNodeCollection[] nodes = new TreeNodeCollection[treeView1.Nodes.Count];
               treeView1.Nodes.CopyTo(nodes, 0);
               treeView1.Nodes.Clear();//get rid of this BEFORE we're done.
               treeView1.Nodes.AddRange(NodeBuilder.BuildNodes(treeView1.Nodes, db.Authors, db.Books, filter));

           }
       }


then i'm calling the modified class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using momdb;

namespace Utilties
{
    public sealed class NodeBuilder
    {
        // public static void BuildNodes(TreeNodeCollection nodes,IEnumerable<Author>authors, IEnumerable<Book> books, string filter)
         public static TreeNode[] BuildNodes(TreeNodeCollection nodes,IEnumerable<Author>authors,IEnumerable<Book>books,string filter)
       {
            TreeNode node = new TreeNode();
           
            if (filter == "Keywords")
              {
                  node = nodes.Add("Keywords");
                
                  books.ToList().ForEach(m =>
                    {
                        node.Nodes.Add(m.Keywords);
                        node.Tag = filter;
                        
                        
                    });
               
            }
            if (filter == "Title")
            {
                node = nodes.Add("Title");
                books.ToList().ForEach(m =>
                    {
                        node.Nodes.Add(m.Title);
                        node.Tag = filter;
                    });
            }
           if (filter =="Author")
           {
               node = nodes.Add("Authors");
               authors = authors.ToList().Distinct();
               authors.ToList().ForEach(m =>
                {
                 node.Nodes.Add(string.Format("{0},{1}",m.AuthorFirst,m.AuthorLast));

                    //node.Nodes.Add("testing");
                    
                    node.Tag=filter;
                
                 }); 
           }
           TreeNode[] holder = new TreeNode[node.Nodes.Count];
           for (int i = 0; i < node.Nodes.Count; i++)
           {

               holder[i] = node.Nodes[i];
           }

           return holder;
        }
      
    }
}


still confused Frown | :( Confused | :confused:
GeneralRe: treenodecollection nodes not working as expected with created class Pin
Dan Mos18-Feb-10 13:34
Dan Mos18-Feb-10 13:34 
GeneralRe: treenodecollection nodes not working as expected with created class Pin
tonyonlinux19-Feb-10 17:00
tonyonlinux19-Feb-10 17:00 
QuestionHow to set a property in a collection based on the join? Pin
sri_346417-Feb-10 20:04
sri_346417-Feb-10 20:04 
AnswerRe: How to set a property in a collection based on the join? Pin
Dan Mos17-Feb-10 20:36
Dan Mos17-Feb-10 20:36 
QuestionSaving Data on a Form Pin
thomas_anderson17-Feb-10 18:00
thomas_anderson17-Feb-10 18:00 
AnswerRe: Saving Data on a Form Pin
AspDotNetDev17-Feb-10 18:33
protectorAspDotNetDev17-Feb-10 18:33 
GeneralRe: Saving Data on a Form Pin
thomas_anderson17-Feb-10 20:23
thomas_anderson17-Feb-10 20:23 

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.