Click here to Skip to main content
15,672,024 members
Home / Discussions / C#
   

C#

 
AnswerRe: Reading specif Excel sheet headers Pin
Calin Tatar28-Feb-09 16:12
Calin Tatar28-Feb-09 16:12 
GeneralRe: Reading specif Excel sheet headers Pin
alvas893-Mar-09 9:08
alvas893-Mar-09 9:08 
AnswerRe: Reading specif Excel sheet headers Pin
0x3c01-Mar-09 0:03
0x3c01-Mar-09 0:03 
GeneralRe: Reading specif Excel sheet headers Pin
alvas893-Mar-09 9:12
alvas893-Mar-09 9:12 
QuestionCD Image in C# [modified] Pin
Demasoni28-Feb-09 9:54
Demasoni28-Feb-09 9:54 
AnswerRe: CD Image in C# Pin
harold aptroot28-Feb-09 10:41
harold aptroot28-Feb-09 10:41 
AnswerRe: CD Image in C# Pin
Henry Minute1-Mar-09 2:01
Henry Minute1-Mar-09 2:01 
QuestionTo display Node atrributes such that node name is added to tree? Pin
rasingh128-Feb-09 8:23
rasingh128-Feb-09 8:23 
Hi,
Here i want to improve display of node attributes such that only node name is added to tree and attributes of clicked node appear in GUI controls on right hand side of form.
NodeType is of enumarated type XmlNodeType, yet the values are compared as strings.What should be there instead of strings?How to use enumerated data types?
How to get rid of While loop in Treeview1_AfterSelect(), it may go in infinite loop?
Please help out in providing right part of code to be used..
Thanks in advance..
public partial class TreeDisplay : Form     
    {     
        public string Filename     
        { get { return filename; }        }     
        protected string filename; 
        private void initiatingTree(string nameofFile)     
        {     
         treeView1.Nodes.Clear();     
         if (xmlDocument.DocumentElement != null) treeView1.Nodes.Add(new TreeNode (xmlDocument.DocumentElement.Name));     
                TreeNode tNodeObj = treeView1.Nodes[0];     
                XmlNode xNode = xmlDocument.DocumentElement;     
                AddingNodesToTree(xNode,tNodeObj);     
                treeView1.Nodes[0].Expand();     
                treeView1.CollapseAll();                
        }//initiatingTree     
        //Method to add Nodes to tree     
        private static void AddingNodesToTree(XmlNode xmlNode,TreeNode tnode)     
        {  //Adding nodes to tree while looping through the entire XML file     
            if (xmlNode.HasChildNodes)     
            {   
                XmlNodeList nodeList = xmlNode.ChildNodes;                    
                for (int i = 0; i <= nodeList.Count - 1; i++)     
                {   XmlNode xmladdtreeNode = xmlNode.ChildNodes[i];     
                    String nodetype = "" + xmladdtreeNode.NodeType;     
                    if (nodetype.Equals("Text") || nodetype.Equals("Comment"))   
                    {     
                     tnode.Nodes.Add(new TreeNode(xmladdtreeNode.InnerText));               
                    }     
                    else    
                      {   
                        String name = "<" + xmladdtreeNode.Name;     
                        XmlAttributeCollection attCol = xmladdtreeNode.Attributes;    
                        foreach (XmlAttribute xmlatt in attCol)     
                        {     
                        name += " " + xmlatt.Name + "=\"" + xmlatt.Value + "\"";     
                        }     
                        name +=  ">";     
                        TreeNode tn = new TreeNode(xmladdtreeNode.Name);     
                        tn.Text = name;     
                        tnode.Nodes.Add(tn);     
                        TreeNode treeNode = tnode.Nodes[i];     
                        AddingNodesToTree(xmladdtreeNode,treeNode);     
                        }     
                }//for     
            }//if     
          else    
            {  tnode.Text = xmlNode.OuterXml.Trim();     
            }//else      
        }//AddingNodesToTree     
        private void treeView1_AfterSelect(object sender,TreeViewEventArgs e)     
        {     
            listBox1.Items.Clear();     
            TreeNode treenode = e.Node;   //Node selected in Treeview               
            String text = treenode.Text;     
            String relevent = text;     
            Boolean flag = true;     
            while (flag)     
            {   int SpaceIndex = relevent.IndexOf(" ");     
                if (SpaceIndex != -1)     
                {   int indexofEqual = relevent.IndexOf('=', SpaceIndex);     
                    if (indexofEqual != -1)     
                    { int indexOFValue = relevent.IndexOf("\"", indexofEqual + 2);     
                        if (indexOFValue != -1)     
                        { 
 String attribute = relevent.Substring(SpaceIndex + 1, indexofEqual - SpaceIndex - 1);      
   String value = relevent.Substring(indexofEqual + 2, indexOFValue - indexofEqual - 2);     
         listBox1.Items.Add("Attribute:" + attribute + "Value:" +value);                     
                     releventreleventreleventrelevent = relevent.Substring(indexOFValue);   
                        }   
                        else   
                        {  listBox1.Items.Add("Bad format of the xml file for this node");   
                            flag = false;   
                        }  }   
                    else   
                    {    flag = false;   
                    }   }   
                else   
                {   flag = false;     }   
            }   }//AfterSelect()          
         }// TreeDisplay Class  

Questionwindows version check Pin
shabya28-Feb-09 7:26
shabya28-Feb-09 7:26 
AnswerRe: windows version check Pin
harold aptroot28-Feb-09 7:30
harold aptroot28-Feb-09 7:30 
GeneralRe: windows version check Pin
0x3c028-Feb-09 8:15
0x3c028-Feb-09 8:15 
GeneralRe: windows version check Pin
harold aptroot28-Feb-09 8:42
harold aptroot28-Feb-09 8:42 
GeneralRe: windows version check Pin
shabya28-Feb-09 9:36
shabya28-Feb-09 9:36 
GeneralRe: windows version check Pin
harold aptroot28-Feb-09 10:17
harold aptroot28-Feb-09 10:17 
AnswerRe: windows version check Pin
Ravi Bhavnani28-Feb-09 8:48
professionalRavi Bhavnani28-Feb-09 8:48 
QuestionStrip progress bar using background thread while uploading file in C#? Pin
rasingh128-Feb-09 7:10
rasingh128-Feb-09 7:10 
AnswerRe: Strip progress bar using background thread while uploading file in C#? Pin
Ravi Bhavnani28-Feb-09 8:49
professionalRavi Bhavnani28-Feb-09 8:49 
QuestionRe: Strip progress bar using background thread while uploading file in C#? Pin
rasingh128-Feb-09 20:18
rasingh128-Feb-09 20:18 
AnswerRe: Strip progress bar using background thread while uploading file in C#? Pin
Ravi Bhavnani28-Feb-09 20:24
professionalRavi Bhavnani28-Feb-09 20:24 
GeneralRe: Strip progress bar using background thread while uploading file in C#? Pin
rasingh12-Mar-09 0:42
rasingh12-Mar-09 0:42 
GeneralRe: Strip progress bar using background thread while uploading file in C#? Pin
Ravi Bhavnani2-Mar-09 3:44
professionalRavi Bhavnani2-Mar-09 3:44 
GeneralRe: Strip progress bar using background thread while uploading file in C#? Pin
rasingh14-Mar-09 17:10
rasingh14-Mar-09 17:10 
GeneralRe: Strip progress bar using background thread while uploading file in C#? Pin
Ravi Bhavnani4-Mar-09 17:47
professionalRavi Bhavnani4-Mar-09 17:47 
GeneralRe: Strip progress bar using background thread while uploading file in C#? Pin
rasingh14-Mar-09 18:27
rasingh14-Mar-09 18:27 
QuestionFile caching C# Pin
satsumatable28-Feb-09 5:53
satsumatable28-Feb-09 5:53 

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.