1

My problem is Saving Button location in XML file. My Form have button that are draggable on edit form, so when i am finished editing the form i want to save Button location in XML file, so then i can read the location from the XML file and display the button on the modified position.

Any Suggestions?

4
  • Can't You just read Button.Top and Button.Left properties and save them in xml ? Commented May 19, 2015 at 8:41
  • 1
    So just save the locations of your buttons in an xml file. Where exactly are you stuck? Commented May 19, 2015 at 8:42
  • Is your problem to create & || read an XML file? Commented May 19, 2015 at 8:49
  • Your question is too broad and it's unclear what the problem is. Please edit your question to follow the suggestions in the How to Ask page. Commented May 19, 2015 at 9:01

1 Answer 1

1

Unless it's otherwise a requirement for your application or you need to store additional complex data, you don't really need to create an XML file. You could use a plain text file like this:

var fileContents = string.Format("{0}\r\n{1}\r\n", button.Top, button.Left);
File.WriteAllText("ButtonCoordinates.dat");

Then to read and apply back the coordinates:

var fileContents = File.ReadAllLines("ButtonCoordinates.dat");
button.Top = double.Parse(fileContents[0]);
button.Left = double.Parse(fileContents[1]);

Of course you need to add error checking, file path management et al, but you get the idea.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.