Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/05/2009, 07:12
REHome
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 727
Antigüedad: 17 años
Puntos: 8
Guardar y leer XML.

Hola gente:

Tengo un Form11, un button1 y otro button2 que al pulsarlo crea un XML. La idea es cómo guardar las coordenadas Location y Siza del button1 en XML.

Código:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace Tamaño_Boton
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Location = new Point(52, 12);
            button1.Size = new Size(75, 65);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            XmlWriter w = XmlWriter.Create("Config.xml");
            w.WriteStartElement("Form1");
            w.WriteEndElement();
            w.Close();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                XmlReader r = XmlReader.Create("Config.xml");
                r.ReadStartElement("Form1");
                r.ReadEndElement();
                r.Close();
            }
            catch
            {
                // No se encuentra el archivo.
            }
        }
    }
}
Hasta otra.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar