Hi,
My problem is
I want to configure C# window application using xml file ...like main c# window consists of two steps, and each step has sub steps. when the application loads step-1 should get activated and it has sub-steps, so it should automatically reconfigured during runtime and the user form should change to 1.1 and 1.2(all these should happen in a single c# window form) and each step has a xml file related to it ,information entered in each step should go to the corresponding xml file. When the user finishes step 1.1 and 1.2 it should go back to step-1 and then step-2 should get activated and same process to be followed for step-2.For your reference I have drawn a sample picture of my application. Since I am new to this field please give me some ideas like how to design a user form that changes in run time according to the xml config file.
Thanks in advance,
Hari purushothaman
hari purushothamanPosted Jun 12, 2008, 1:24 AM
Hi mike,
Thanks for your reply...I have created a xml schema and also designed my layout corresponding to my xml schema.And i can able to export my values in the form into the xml file...now my problem is the form layout should change in runtime(like step-1 to step-1.1 and 1.2)and based on that my values should be entered into xml file(Like each step has different xml file).Below is my sample xml file and coding what i have done.can u help with a bit of code for my problem which will be useful for my development..
xml file:
coding:
private void button2_Click(object sender, EventArgs e)
{
public DataSet dspay;
public string strPayroll;
public string q,q1,q2,q3,q4;
obj.q = textBox10.Text;
obj.q1 = textBox11.Text;
obj.q2 = textBox12.Text;
obj.q3 = textBox13.Text;
obj.q4 = textBox14.Text;
obj.Payrollinfo();
dataGridView3.DataSource = obj.dspay;
dataGridView3.DataMember = "Description";
}
public void Payrollinfo()
{
// Method to create the "EmpDetails" xml file
strPayroll = @"E:\EMS (R&D)\Hari eg(c# coding)\EMS process interface\hari template\Payrollinfo.xml";
XmlDocument xmlDoc1 = new XmlDocument();
try
{
xmlDoc1.Load(strPayroll);
}
catch (System.IO.FileNotFoundException)
{
//if file is not found, create a new xml file
XmlTextWriter xmlWriter = new XmlTextWriter(strPayroll, System.Text.Encoding.UTF8);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
xmlWriter.WriteStartElement("Payroll");
xmlWriter.Close();
xmlDoc1.Load(strPayroll);
}
XmlNode nd1 = xmlDoc1.DocumentElement;
XmlElement nd2 = xmlDoc1.CreateElement("Description");
XmlElement nd3 = xmlDoc1.CreateElement("AccountNo");
XmlElement nd4 = xmlDoc1.CreateElement("Basic");
XmlElement nd5 = xmlDoc1.CreateElement("Conveyance");
XmlElement nd6 = xmlDoc1.CreateElement("HRA");
XmlElement nd7 = xmlDoc1.CreateElement("Others");
nd1.AppendChild(nd2);
nd2.AppendChild(nd3);
nd2.AppendChild(nd4);
nd2.AppendChild(nd5);
nd2.AppendChild(nd6);
nd2.AppendChild(nd7);
nd3.InnerText = q;
nd4.InnerText = q1;
nd5.InnerText = q2;
nd6.InnerText = q3;
nd7.InnerText = q4;
xmlDoc1.Save(strPayroll);
//code for filling datagridview
dspay = new DataSet();
dspay.ReadXml(strPayroll);
}
Mike GoldPosted Jun 11, 2008, 5:03 PM
You'll need to do quite a bit of coding to get this to happen.
1) You'll need to come out with an appropriate xml schema that describes the controls and layout of your form.
2) you'll need to write something that parses your xml to pull out your form layout information
2) you'll need to create and layout controls on the form according to the xml specification.
Of course, you may be able to use some sort of XAML solution which already describes controls on a form in XML.