469,626 Members | 901 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

how to check unchek checkboxes using xml

i have an xml file, i have to enable or disable checkboxes based on these valuse


Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <ModulesAvalable>
  3.  
  4.     <Module name="calculator" hasdatabase="False" enabled="True"></Module>
  5.     <Module name="employeemanager" hasdatabase="True"  enabled="False"></Module>
  6.     <Module name="Central Office" hasdatabase="False" enabled="True"></Module>
  7.     <Module name="emp/emp Manager" hasdatabase="True" enabled="True"></Module>
  8.  
  9. </ModulesAvalable>
so how to do this
Apr 6 '06 #1
1 5656
<?xml version="1.0" encoding="utf-8" ?>
<ModulesAvailable>
<Module>
<NAME>FRE</NAME>
<HASDATABASE>FALSE</HASDATABASE>
<ENABLED>FALSE</ENABLED>
</Module>
<Module>
<NAME>CENTRALOFFICE</NAME>
<HASDATABASE>FALSE</HASDATABASE>
<ENABLED>FALSE</ENABLED>
</Module>


<Module>
<NAME>POS</NAME>
<HASDATABASE>TRUE</HASDATABASE>
<ENABLED>TRUE</ENABLED>
</Module>

<Module>
<NAME>POS/POSMANAGER</NAME>
<HASDATABASE>TRUE</HASDATABASE>
<ENABLED>TRUE</ENABLED>
</Module>
</ModulesAvailable>

we r reading data from this file to check or uncheck the checkboxes


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Xml;



() cashier
() central server option button
() manager

[] install database checkbox

here checkbox must be unchecked for cashier and central server for manager its enabled
so we do this using this code








using System.Windows.Forms;

namespace ReadmeDilogue
{
public partial class ReadmeForm : Form
{
bool InstallDb = false;


public ReadmeForm(bool installDatabase)
{
InstallDb = installDatabase;



InitializeComponent();
}


private void ReadmeForm_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml("D:\\PRS\\EXAMP\\New Folder\\ReadmeDilogue\\ReadmeDilogue\\DATA.xml");

try
{

if (Convert.ToBoolean(ds.Tables[0].Rows[0][2]) == false)
{
radioButton0.Enabled = false;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[1][2]) == false)
{
radioButton1.Enabled = false;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[2][2]) == false)
{
radioButton2.Enabled = false;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[3][2]) == false)
{
radioButton3.Enabled = false;
}
for (int i = 0; i <= ds.Tables[0].Rows.Count-1; i++)
{
if (Convert.ToBoolean(ds.Tables[0].Rows[i][2]) == true)
{

if (Convert.ToBoolean(ds.Tables[0].Rows[i][1]) == true)
{
checkBox2.Enabled = true;
}
else
{
checkBox2.Enabled = false;
}
}

}
}
catch (Exception de)
{
Console.WriteLine("Exception: {0}", de.ToString());
}

}


//getting value of installDb (TRUE|FALSE)

public bool InstallDB
{
get { return this.checkBox2.Checked; }
}


public void change_color()
{
button1.BackColor = System.Drawing.Color.Gold;


}


private void button1_Click(object sender, EventArgs e)
{


MessageBox.Show(Convert.ToString(InstallDB));


this.Close();
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{


}




/// <summary>
/// the install database checkbox will be disabled if FRE or CENTRAL SERVER is selected
/// here we are also unchecking the install database checkbox if it is alredy checked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>



private void radioButton0_CheckedChanged_1(object sender, EventArgs e)
{
checkBox2.Checked = false;

if (radioButton0.Checked == false)
{
checkBox2.Enabled = true;
}
else if (radioButton0.Checked == true)
{

checkBox2.Enabled = false;
}
}

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
checkBox2.Checked = false;

if (radioButton1.Checked == true)
{
checkBox2.Enabled = false;
}
else if (radioButton1.Checked == false)
{

checkBox2.Enabled = true;
}

}

// InstallDatabase Checkbox will be enabled if pos or posManager is selected

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked == true)
{
checkBox2.Enabled = true;
}
else if (radioButton2.Checked == false)
{

checkBox2.Enabled = false;
}
}

private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
if (radioButton3.Checked == true)
{
checkBox2.Enabled = true;
}
else if (radioButton3.Checked == false)
{

checkBox2.Enabled = false;
}

}



}
}
Apr 10 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by arenaTR | last post: by
13 posts views Thread by Adrian Parker | last post: by
6 posts views Thread by terence.parker | last post: by
7 posts views Thread by Jaime Stuardo | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.