Click here to Skip to main content
15,902,835 members
Home / Discussions / C#
   

C#

 
QuestionXML in C# Pin
Kris10027-Jun-07 13:12
Kris10027-Jun-07 13:12 
AnswerRe: XML in C# Pin
max2929727-Jun-07 13:34
max2929727-Jun-07 13:34 
AnswerRe: XML in C# Pin
Amit Kumar G27-Jun-07 13:49
Amit Kumar G27-Jun-07 13:49 
AnswerRe: XML in C# Pin
Christian Graus27-Jun-07 14:01
protectorChristian Graus27-Jun-07 14:01 
GeneralRe: XML in C# Pin
Mark Greenwood27-Jun-07 14:58
Mark Greenwood27-Jun-07 14:58 
AnswerRe: XML in C# Pin
Kris10028-Jun-07 2:39
Kris10028-Jun-07 2:39 
GeneralRe: XML in C# Pin
max2929728-Jun-07 11:55
max2929728-Jun-07 11:55 
GeneralRe: XML in C# Pin
max2929728-Jun-07 12:22
max2929728-Jun-07 12:22 
Okay, here's the finished code:

using System;<br />
using System.Windows.Forms;<br />
using System.Drawing;<br />
using System.Xml;<br />
using System.Collections;<br />
<br />
class Run : Form {<br />
   ArrayList titles;<br />
   ArrayList descriptions;<br />
   ArrayList images;<br />
   int index;<br />
   <br />
   TextBox titleBox;<br />
   TextBox descriptionBox;<br />
    PictureBox imageBox;<br />
   Button nextButton;<br />
   Button prevButton;<br />
   <br />
   public Run() {<br />
      XmlTextReader reader = new XmlTextReader("file.xml");<br />
      <br />
      index = 0;<br />
      titles = new ArrayList();<br />
      descriptions = new ArrayList();<br />
      images = new ArrayList();<br />
      <br />
      reader.MoveToContent();<br />
      while (reader.Read()) {<br />
         if (reader.NodeType == XmlNodeType.Element) {<br />
            switch (reader.Name) {<br />
               case "Title":<br />
                  titles.Add(reader.ReadString());<br />
                  break;<br />
               case "Description":<br />
                  descriptions.Add(reader.ReadString());<br />
                  break;<br />
               case "Image":<br />
                  images.Add(reader.ReadString());<br />
                  break;<br />
            }<br />
         }<br />
      }<br />
      <br />
      reader.Close();<br />
      <br />
      this.Size = new Size(520, 430);<br />
      <br />
      titleBox = new TextBox();<br />
      titleBox.Text = (string)titles[index];<br />
      titleBox.Location = new Point(5, 5);<br />
      titleBox.Size = new Size(300, 25);<br />
      this.Controls.Add(titleBox);<br />
      <br />
      descriptionBox = new TextBox();<br />
      descriptionBox.Text = (string)descriptions[index];<br />
      descriptionBox.Multiline = true;<br />
      descriptionBox.Location = new Point(5, 50);<br />
      descriptionBox.Size = new Size(300, 300);<br />
      this.Controls.Add(descriptionBox);<br />
      <br />
      imageBox = new PictureBox();<br />
      imageBox.Image = Image.FromFile((string)images[index]);<br />
      imageBox.Location = new Point(310, 50);<br />
      imageBox.Size = new Size(100, 100);<br />
      this.Controls.Add(imageBox);<br />
      <br />
      prevButton = new Button();<br />
      prevButton.Text = "<--";<br />
      prevButton.Location = new Point(5, 350);<br />
      prevButton.Click += new EventHandler(UpdateInfo);<br />
      this.Controls.Add(prevButton);<br />
      <br />
      nextButton = new Button();<br />
      nextButton.Text = "-->";<br />
      nextButton.Location = new Point(90, 350);<br />
      nextButton.Click += new EventHandler(UpdateInfo);<br />
      this.Controls.Add(nextButton);<br />
   }<br />
   <br />
   public void UpdateInfo(object sender, EventArgs e) {<br />
      if (((Button)sender).Text == "-->") {<br />
         index++;<br />
         if (index >= titles.Count)<br />
            index = 0;<br />
      } else {<br />
         index--;<br />
         if (index < 0)<br />
            index = titles.Count-1;<br />
      }<br />
      <br />
      titleBox.Text = (string)titles[index];<br />
      descriptionBox.Text = (string)descriptions[index];<br />
      imageBox.Image = Image.FromFile((string)images[index]);<br />
   }<br />
   <br />
   static void Main() {<br />
      Application.EnableVisualStyles();<br />
      Application.Run(new Run());<br />
   }<br />
}

I tested it, and it works. Just change the name of the xml file to "file.xml".

-----
*** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***

QuestionApplication Properties? Pin
max2929727-Jun-07 12:51
max2929727-Jun-07 12:51 
AnswerRe: Application Properties? Pin
J$27-Jun-07 13:27
J$27-Jun-07 13:27 
GeneralRe: Application Properties? Pin
max2929727-Jun-07 13:31
max2929727-Jun-07 13:31 
GeneralRe: Application Properties? Pin
Luc Pattyn27-Jun-07 14:28
sitebuilderLuc Pattyn27-Jun-07 14:28 
AnswerRe: Application Properties? Pin
Luc Pattyn27-Jun-07 14:37
sitebuilderLuc Pattyn27-Jun-07 14:37 
QuestionInfo about sound from microphone Pin
Joseph133727-Jun-07 12:13
Joseph133727-Jun-07 12:13 
AnswerRe: Info about sound from microphone Pin
Christian Graus27-Jun-07 14:03
protectorChristian Graus27-Jun-07 14:03 
AnswerRe: Info about sound from microphone Pin
Luc Pattyn27-Jun-07 14:53
sitebuilderLuc Pattyn27-Jun-07 14:53 
AnswerRe: Info about sound from microphone Pin
Leslie Sanford27-Jun-07 16:39
Leslie Sanford27-Jun-07 16:39 
QuestionOWC Excel Problem Pin
TheMajorRager27-Jun-07 11:38
TheMajorRager27-Jun-07 11:38 
AnswerRe: OWC Excel Problem Pin
Dave Kreskowiak27-Jun-07 12:01
mveDave Kreskowiak27-Jun-07 12:01 
QuestionCan I change the Opacity of control units in a form? Pin
Khoramdin27-Jun-07 10:35
Khoramdin27-Jun-07 10:35 
AnswerRe: Can I change the Opacity of control units in a form? Pin
Ed.Poore27-Jun-07 10:43
Ed.Poore27-Jun-07 10:43 
AnswerRe: Can I change the Opacity of control units in a form? Pin
Dave Kreskowiak27-Jun-07 11:57
mveDave Kreskowiak27-Jun-07 11:57 
QuestionImage Processing: Redraw the outline of any image (sketching) in C#.Net, but How?? Pin
zeeShan anSari27-Jun-07 9:44
zeeShan anSari27-Jun-07 9:44 
AnswerRe: Image Processing: Redraw the outline of any image (sketching) in C#.Net, but How?? Pin
Luc Pattyn27-Jun-07 10:16
sitebuilderLuc Pattyn27-Jun-07 10:16 
AnswerRe: Image Processing: Redraw the outline of any image (sketching) in C#.Net, but How?? Pin
Christian Graus27-Jun-07 10:47
protectorChristian Graus27-Jun-07 10:47 

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.