Click here to Skip to main content
15,893,668 members
Home / Discussions / C#
   

C#

 
QuestionError reading word doc using Micorsoft.Office.Interop(Object library) via IIS 7 Pin
sudeep vajrala2-Jan-12 19:46
sudeep vajrala2-Jan-12 19:46 
AnswerRe: Error reading word doc using Micorsoft.Office.Interop(Object library) via IIS 7 Pin
manognya kota3-Jan-12 19:10
manognya kota3-Jan-12 19:10 
Question[SOLVED] - DataGridView - Object can not be cast 'From DBNullto Other Types' Pin
AmbiguousName2-Jan-12 19:17
AmbiguousName2-Jan-12 19:17 
AnswerRe: DataGridView - Object can not be cast 'From DBNullto Other Types' Pin
V.2-Jan-12 20:15
professionalV.2-Jan-12 20:15 
GeneralRe: DataGridView - Object can not be cast 'From DBNullto Other Types' Pin
AmbiguousName3-Jan-12 19:04
AmbiguousName3-Jan-12 19:04 
AnswerRe: DataGridView - Object can not be cast 'From DBNullto Other Types' Pin
PIEBALDconsult3-Jan-12 2:25
mvePIEBALDconsult3-Jan-12 2:25 
Questioncall database sql server 2008 in c# Pin
tito0306902-Jan-12 14:45
tito0306902-Jan-12 14:45 
AnswerRe: call database sql server 2008 in c# Pin
OriginalGriff2-Jan-12 21:21
mveOriginalGriff2-Jan-12 21:21 
Questionthe counter reading program in c # Pin
mfy402-Jan-12 12:35
mfy402-Jan-12 12:35 
AnswerRe: the counter reading program in c # Pin
BillWoodruff2-Jan-12 14:20
professionalBillWoodruff2-Jan-12 14:20 
Questionhow to copy cheked nodes from a treeview to to new treeview? Pin
JANARDHAN GURRAM2-Jan-12 7:08
JANARDHAN GURRAM2-Jan-12 7:08 
AnswerRe: how to copy cheked nodes from a treeview to to new treeview? Pin
Pete O'Hanlon2-Jan-12 10:34
mvePete O'Hanlon2-Jan-12 10:34 
GeneralRe: how to copy cheked nodes from a treeview to to new treeview? Pin
JANARDHAN GURRAM2-Jan-12 21:23
JANARDHAN GURRAM2-Jan-12 21:23 
GeneralRe: how to copy cheked nodes from a treeview to to new treeview? Pin
Pete O'Hanlon2-Jan-12 21:36
mvePete O'Hanlon2-Jan-12 21:36 
GeneralRe: how to copy cheked nodes from a treeview to to new treeview? Pin
JANARDHAN GURRAM2-Jan-12 21:59
JANARDHAN GURRAM2-Jan-12 21:59 
AnswerRe: how to copy cheked nodes from a treeview to to new treeview? Pin
BillWoodruff2-Jan-12 14:10
professionalBillWoodruff2-Jan-12 14:10 
GeneralRe: how to copy cheked nodes from a treeview to to new treeview? Pin
JANARDHAN GURRAM2-Jan-12 21:40
JANARDHAN GURRAM2-Jan-12 21:40 
GeneralRe: how to copy cheked nodes from a treeview to to new treeview? Pin
BillWoodruff2-Jan-12 23:04
professionalBillWoodruff2-Jan-12 23:04 
Well, we are making progress in defining the actual structure of your TreeView ... and that's good Smile | :)

This reply raises these questions, for me:

0. is any node in the TreeView ever more than 3 levels deep: in other words: is the level of "nesting" arbitrary ? In other words: is there any regular structure to all nodes that we can assume: for example: they are all 3 levels "deep" ?

1. in the case of one node, which is the only child of its parent: you say the parent should also be unchecked: what about if that parent node is also the "only child" of its parent node: does its "grandfather" then get unchecked ?

a. what if the grandparent node of the only child of the parent node that is unchecked has many other child nodes ... "uncle nodes" ? Smile | :) ... what happens to them: do they get left alone, or unchecked, also ?

2. if a parent node is unchecked: and that parent node has many levels of nested nodes "under it:" do they all get unchecked ... or only the "grandchildren" of that node get unchecked: this would be "symmetric" with the way you now handle unchecking an only child of a node, then its parent, and then its grandparent.

2. is it ever the case that:

a. new nodes are added at run-time ?

b. existing nodes are deleted at run-time ?

To get you started with recursive parsing: put a TreeView on a Form:

0. in the Form Load EventHandler set the 'Expanded property of the TreeView to 'true.

1. edit the Nodes collection at Design-Time, and add a whole bunch of them, nested to various depths

2. set the TreeView 'CheckBoxes property to 'True:

3. put a button on the Form with its Click EventHandler set like so:
C#
private void button1_Click(object sender, EventArgs e)
{
   // show all the nodes expanded
   treeView1.ExpandAll();

   RecursiveParseTree(treeView1.Nodes, 0);
}
4. And then define the recursive parser:
private void RecursiveParseTree(TreeNodeCollection nodeCollection, int level)
{
    foreach (TreeNode theNode in nodeCollection)
    {
        Console.WriteLine
        (
            "Node Name: = {0}, 
            Node Level = {1}, 
            Node Checked = {2}", 
            theNode.Text, 
            level, 
            theNode.Checked
        );

        if (theNode.Nodes.Count > 0)
        {
            RecursiveParseTree(theNode.Nodes, level++);
        }
    }
}
5. At run-time check a bunch of nodes at various "depths," and examine the output of running this code in VS's Output Window when you exit the Application.

Discussion: the interesting part is going to be where you get to all the business related to unchecking only-child nodes, and grandparent nodes !

best, Bill
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle


modified 3-Jan-12 5:25am.

GeneralRe: how to copy cheked nodes from a treeview to to new treeview? Pin
JANARDHAN GURRAM2-Jan-12 23:49
JANARDHAN GURRAM2-Jan-12 23:49 
GeneralRe: how to copy cheked nodes from a treeview to to new treeview?<SOLVED> Pin
JANARDHAN GURRAM3-Jan-12 1:06
JANARDHAN GURRAM3-Jan-12 1:06 
GeneralRe: how to copy cheked nodes from a treeview to to new treeview? Pin
BillWoodruff3-Jan-12 2:51
professionalBillWoodruff3-Jan-12 2:51 
GeneralRe: how to copy cheked nodes from a treeview to to new treeview? Pin
JANARDHAN GURRAM5-Jan-12 18:17
JANARDHAN GURRAM5-Jan-12 18:17 
GeneralRe: how to copy cheked nodes from a treeview to to new treeview? Pin
BillWoodruff5-Jan-12 22:38
professionalBillWoodruff5-Jan-12 22:38 
GeneralRe: how to copy cheked nodes from a treeview to to new treeview?<SOLVED> Pin
JANARDHAN GURRAM3-Jan-12 1:14
JANARDHAN GURRAM3-Jan-12 1:14 
QuestionProblem with Snake game in C# Pin
ori26942-Jan-12 3:20
ori26942-Jan-12 3:20 

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.