Windows Develop Bookmark and Share   
 index > Windows Forms General > noob: Load Config.XML file
 

noob: Load Config.XML file

Hi All... This is my first time working with XML so please bare with me

I have a form with 18 textboxes and i can save the textbox data to XML fine... I just cannot read it back and Load the settings to the correct textboxes:???

Code Block

Write to XML by Using:

ItemInfo[] infos = new ItemInfo[this.Controls.Count];

for (int i = 0; i < this.Controls.Count; i++)

if (this.Controls[i] is TextBox)

{

infos[i] = ItemInfo.FromTB(this.Controls[i] as TextBox);

}

XmlConfigHelper.SetTBItems(infos);

The result of the XML file isSadshort snippet)

<Settings>
<TextBoxes>
<Item>
<DisplayName>q6</DisplayName><--TextBox name -->

<Location>319,108</Location> <--TextBox Location -->
<Value>234</Value> <--TextBox.Text Value-->
</Item>

</TextBoxes>

</Settings>

I have tried various methods to load this file and my last attempt is below: So any help with this is more than welcome before tall buildings become appealing ... ..thankyou in Advance...

Code Block

private void LoadSettings()

{

ItemInfo[] infos = XmlConfigHelper.GetTBItems();

for (int i = 0; i < infos.Length; i++)

{

setTextBox(a[i], infos[i]); //a = textbox array

}

}

void setTextBox(TextBox tb, ItemInfo info)

{

tb.Name = info.name; //returns null reference exception??????

tb.Location = info.TBLocation;

tb.Text = info.value;

}

Simon bridgens  Friday, October 05, 2007 7:14 PM
this is fixed now.... It needed a rethink and I compared the link below app methods against what i was trying to achieve:

http://www.codeproject.com/useritem...100&msg=2260292
Simon bridgens  Sunday, October 07, 2007 5:05 PM
this is fixed now.... It needed a rethink and I compared the link below app methods against what i was trying to achieve:

http://www.codeproject.com/useritem...100&msg=2260292
Simon bridgens  Sunday, October 07, 2007 5:05 PM

You can use google to search for other answers

Custom Search

More Threads

• calling a method when the app closes
• Toolstrip XP themes
• Stop default Ctrl-I behaviour in textbox?
• Ever wonder how to delete an Image from a control after an event has been triggered?
• Pixel Format in GDI+ and WPF Question
• How to build a jog control
• how to use command builder class
• Cursors.WaitCursor not sticking... help?
• In search of a collapsible panel
• Emoticons in RichTextBox