大概的情况是用splitcontainer 把桌面分成两部分,当用户自己设置两部分的大小后,下次重起时出现的是上次的大小.要求写到 CONFIG 文件中.

解决方案 »

  1.   

    写xml文件应该不难啊,自己去试试应该没什么问题。
      

  2.   

    可是头让写到CONFIG 文件中,郁闷
      

  3.   

    楼上的兄弟说得对,这个问题这么简单
    把form的Piont,Height,Width读出来,
    然后持久化就可以了,比如放在xml文件中,
    或者放在ini文件中,或者放在数据库中,
    用户打开时在show的时候加载就可以了。
      

  4.   

    继续等,谢谢Snowdust(雪尘)和guitar__(),各得10分.给代码的加50分
      

  5.   

    XML文件:
    <?xml version="1.0" encoding="utf-8" ?>
    <config>
      <Width>200</Width>
      <Height>200</Height>
    </config>读取及写入:
    XmlDocument doc = new XmlDocument();
    string fileName = Application.StartupPath + "//Config.xml";
    doc.Load(fileName);
    int width = Convert.ToInt32(doc.SelectSingleNode("//Width").ChildNodes[0].Value);
    int height = Convert.ToInt32(doc.SelectSingleNode("//Height").ChildNodes[0].Value);
    doc.SelectSingleNode("//Width").ChildNodes[0].Value = "400";
    doc.SelectSingleNode("//Height").ChildNodes[0].Value = "300";
    doc.Save(fileName);
      

  6.   

    谢谢Snowdust(雪尘),但是老板要求写到USER.CONFIG文件中,这是一个PROJECT 的一部分.为了协调统一,要用CONFIGURATIONMANAGER.APPSETTINGS的命令写,现在我一直搞不懂怎样使定义的KEY 与我要改写的FORM 连在一起.
      

  7.   

    呵呵,在App.Config中更简单。明天给你代码,今天太晚了。
      

  8.   

    using System;
    using System.Xml;
    using System.Windows.Forms;namespace Common
    {
    /// <summary>
    /// 模块名称: 读写系统配置类
    /// 作    者: Snowdust
    /// 编写日期: 2005-12-01
    /// </summary>
    public class AppConfig
    {
    private static bool UpdateConfig(string strKey, string strValue)
    {
    XmlDocument doc = new XmlDocument();
    try
    {
    doc.Load(Application.ExecutablePath + ".config");
    XmlNode node = doc.SelectSingleNode(@"//add[@key='" + strKey + "']");
    XmlElement ele = (XmlElement)node;
    ele.SetAttribute("value", strValue);
    doc.Save(Application.ExecutablePath + ".config");
    }
    catch
    {
    return false;
    }
    return true;
    }
    public AppConfig()
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    }
    public static string GetConfig(string strKey)
    {
    //return System.Configuration.ConfigurationManager.AppSettings[strKey];
    XmlDocument doc = new XmlDocument();
    try
    {
    doc.Load(Application.ExecutablePath + ".config");
    XmlNode node = doc.SelectSingleNode(@"//add[@key='" + strKey + "']");
    XmlElement ele = (XmlElement)node;
    return ele.GetAttribute("value");
    }
    catch
    {
    return string.Empty;
    }
    }
    public static bool SetConfig(string strKey, string strValue)
    {
    return AppConfig.UpdateConfig(strKey, strValue);
    }
    }
    }