110,536
社区成员
发帖
与我相关
我的任务
分享
namespace excusegen.Properties {
sealed partial class Settings : ApplicationSettingsBase {
static Settings defaultInstance =
((Settings)(ApplicationSettingsBase.Synchronized(new Settings( ))));
public static Settings Default {
get { return defaultInstance; }
}
[UserScopedSettingAttribute()]
[DefaultSettingValueAttribute("")]
public string LastExcuse {
get { return ((string)(this["LastExcuse"])); }
set { this["LastExcuse"] = value; }
}
[ApplicationScopedSettingAttribute()]
[DefaultSettingValueAttribute("True")]
public bool ExcludeAnimalExcuses {get { return ((bool)(this["ExcludeAnimalExcuses"])); }
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace 用完删除
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.StartupPath+@"\color.xml");
string[] getxmlcolor = doc.DocumentElement.SelectSingleNode("checkedcolor").InnerText.Split(',');
foreach (string str in getxmlcolor)
{
checkedListBox1.SetItemChecked(int.Parse(str), true);
}
}
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.StartupPath+@"\color.xml");
string xmlupdate = string.Empty;
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
if (checkedListBox1.GetItemChecked(i))
{
xmlupdate += i.ToString() + ",";
}
}
if (xmlupdate.Length > 0)
{
xmlupdate = xmlupdate.Substring(0, xmlupdate.Length - 1);
}
else
{
xmlupdate = "";
}
doc.DocumentElement.SelectSingleNode("checkedcolor").InnerText = xmlupdate;
doc.Save(Application.StartupPath+@"\color.xml");
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<colors>
<checkedcolor>0,2,3</checkedcolor>
</colors>
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load("color.xml");
doc.DocumentElement.SelectSingleNode("checkedcolor").InnerText = checkedListBox1.SelectedItem.ToString()+",";
doc.Save("color.xml");
}