Click here to Skip to main content
15,907,497 members
Home / Discussions / C#
   

C#

 
GeneralRe: synchronized arrayList in C# Pin
Lars Niedziolka28-Jul-05 16:18
Lars Niedziolka28-Jul-05 16:18 
QuestionXmlTextReader - reading from a string? Pin
andrewpritchie28-Jul-05 14:18
andrewpritchie28-Jul-05 14:18 
AnswerRe: XmlTextReader - reading from a string? Pin
Lars Niedziolka28-Jul-05 15:24
Lars Niedziolka28-Jul-05 15:24 
QuestionHow can I... Pin
KORCARI28-Jul-05 12:23
KORCARI28-Jul-05 12:23 
AnswerRe: How can I... Pin
Libor Tinka28-Jul-05 12:39
Libor Tinka28-Jul-05 12:39 
QuestionAlgorithm for creating a list from a hierarchy? Pin
Judah Gabriel Himango28-Jul-05 12:17
sponsorJudah Gabriel Himango28-Jul-05 12:17 
AnswerRe: Algorithm for creating a list from a hierarchy? Pin
Libor Tinka28-Jul-05 12:35
Libor Tinka28-Jul-05 12:35 
AnswerRe: Algorithm for creating a list from a hierarchy? Pin
Lars Niedziolka28-Jul-05 16:00
Lars Niedziolka28-Jul-05 16:00 
Hi Judah,

It's not difficult.

Use following call
ArrayList = ListOfTree(myTree);


and implement ListOfTree with this:
static ArrayList ListOfTree(TreeView tree)
{
  ArrayList list = new ArrayList();
  <small>// Add 1st level:</small>
  list.AddRange(tree.Nodes);

  <small>// Add 2nd, 3rd, 4th,... level</small>
  for (int idx = 0; idx < list.count; idx++)
  {
    list.AddRange(((TreeNode)list[idx]).Nodes);
  }

  <small>// return the result list</small>
  return list;
}


Example:
You have this tree:
Tree
|-A1
| |-B1
| | |-C1
| | +-C2
| +-B2
|   +-C3
+-A2
  +-B3

First you add the Nodes of the tree:
List := A1 A2  [from Tree]

Second you add each child of the already listed nodes: A1 A2
List := A1 A2 B1 B2 [from A1]
List := A1 A2 B1 B2 B3 [from A2]

And so on for each child of B1 .. B3
List := A1 A2 B1 B2 B3 C1 C2 [from B1]
List := A1 A2 B1 B2 B3 C1 C2 C3 [from B2]
List := A1 A2 B1 B2 B3 C1 C2 C3 [from B3]

And so on for each child of C1 .. C3
List := A1 A2 B1 B2 B3 C1 C2 C3 [from C1]
List := A1 A2 B1 B2 B3 C1 C2 C3 [from C2]
List := A1 A2 B1 B2 B3 C1 C2 C3 [from C3]


Have fun,
Niedzi
GeneralRe: Algorithm for creating a list from a hierarchy? Pin
Judah Gabriel Himango28-Jul-05 17:04
sponsorJudah Gabriel Himango28-Jul-05 17:04 
AnswerRe: Algorithm for creating a list from a hierarchy? Pin
leppie28-Jul-05 23:36
leppie28-Jul-05 23:36 
QuestionHow can I.. Pin
KORCARI28-Jul-05 11:50
KORCARI28-Jul-05 11:50 
AnswerRe: How can I.. Pin
Judah Gabriel Himango28-Jul-05 12:04
sponsorJudah Gabriel Himango28-Jul-05 12:04 
General.Using C# dlls in MFC Pin
benwalker28-Jul-05 11:25
benwalker28-Jul-05 11:25 
GeneralRe: .Using C# dlls in MFC Pin
Judah Gabriel Himango28-Jul-05 12:24
sponsorJudah Gabriel Himango28-Jul-05 12:24 
GeneralRe: .Using C# dlls in MFC Pin
Anonymous29-Jul-05 7:14
Anonymous29-Jul-05 7:14 
GeneralAutofill web form Pin
tomc28-Jul-05 10:56
tomc28-Jul-05 10:56 
GeneralImage to WallPaper Pin
sahoREGS28-Jul-05 10:44
sahoREGS28-Jul-05 10:44 
GeneralRe: Image to WallPaper Pin
Matt Gerrans28-Jul-05 12:46
Matt Gerrans28-Jul-05 12:46 
GeneralRe: Image to WallPaper Pin
[Marc]28-Jul-05 21:27
[Marc]28-Jul-05 21:27 
Questioncan we create a button array Pin
iramg28-Jul-05 8:50
iramg28-Jul-05 8:50 
AnswerRe: can we create a button array Pin
Libor Tinka28-Jul-05 9:31
Libor Tinka28-Jul-05 9:31 
GeneralRe: can we create a button array Pin
iramg28-Jul-05 10:22
iramg28-Jul-05 10:22 
GeneralRe: can we create a button array Pin
Judah Gabriel Himango28-Jul-05 12:20
sponsorJudah Gabriel Himango28-Jul-05 12:20 
GeneralRe: can we create a button array Pin
iramg28-Jul-05 23:46
iramg28-Jul-05 23:46 
AnswerRe: can we create a button array Pin
jdkulkarni29-Jul-05 3:01
jdkulkarni29-Jul-05 3:01 

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.