此处系统设置文件名为sysconfig.ini
    子窗体的三个功能:
    <未更改设置前>
    1.childForm_Load中主要先写打开sysconfig的文件,读取文件中的主要的key,给子窗体文本框或者勾选框赋值.
    2.之后利用.Controls[].Height等属性给主窗体中的控件属性设置值
    <更改设置之后>
    3.首先将子窗体(系统设置窗体)中所有设置的参数保存进入sysconfig.ini文件。
    之后仍然利用.Controls[]……..给父窗体赋值

    所以写三个方法:
    1.fileToString方法<暂时有瑕疵,每次想读一个key就得打开文件一次>
    功能:读取filePath,和想要的key,此时注意设置的文本框的名字和想要用的变量名称一致

    1. /// <summary><br /> /// 从”系统设置初值“开始读,读取文件路径中的某个字符串,并且返回设置中的值<br /> /// </summary><br /> /// <param name="filePath"></param><br /> /// <param name="key"></param><br /> /// <returns></returns><br /> // public static string strData = "";<br /> public static string fileToString(string filePath, string key)<br /> {<br /> StreamReader sr = new StreamReader(filePath);<br /> string strData = "";<br /> try<br /> {<br /> string line;<br /> bool condition = true;//控制读到想要的值<br /> while (true)<br /> {<br /> line = sr.ReadLine();<br /> if (line != null && condition)<br /> {<br /> string[] sArray = Regex.Split(line, "=", RegexOptions.IgnoreCase);<br /> for (int i = 0; i < sArray.Length; i++)<br /> {<br /> if (sArray[i] == key)<br /> {<br /> strData = sArray[i + 1];<br /> condition = false;<br /> }<br /> else<br /> {<br /> break;<br /> }<br /> }<br /> }<br /> else<br /> {<br /> break;<br /> }<br /> }<br /> }<br /> catch (Exception ex)<br /> {<br /> MessageBox.Show(ex.ToString());<br /> }<br /> sr.Close();<br /> return strData;<br /> }

    2.saveSet方法保存系统设置的新值—-缺陷:暂时缺少设置控件值的方法

    public void saveSet(string filePath, Control control)
    {
    string newset = “#系统设置新值”;
    bool condition = true;
    StreamWriter sw = new StreamWriter(filePath);
    try
    {
    while (condition)
    {
    foreach (Control c in control.Controls)
    {
    if ((c is TextBox) && (c.Text != null))
    {
    newset += “\r\n” + c.Name + “=” + c.Text;
    }
    if (c is CheckBox && (((CheckBox)c).Checked))
    {
    newset += “\r\n” + c.Name + “=” + “1”;
    }
    if (c is CheckBox && (!((CheckBox)c).Checked))
    {
    newset += “\r\n” + c.Name + “=” + “0”;
    }
    if(!(c is TextBox)&&(c is CheckBox))
    {
    condition = false;
    }
    }
    sw.Write(newset);
    sw.Flush();
    sw.Close();
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(“保存文件出错”);
    MessageBox.Show(ex.ToString());
    }
    }

    3.缺少的控制控件值改变的方法,应该写两个:一个是主窗体主要读取的是初始设置的值。
    还有子窗体设置后改变的值,控制主窗体控件发生变化。————-12.6号写(暂定)