WinForm程序开发
------------------------------主要页面----------------------------------
BaseForm.cs    基类,用于派生子窗口
    
Login.cs    登录,用于登录窗口

MainForm.cs    主页,系统主页

LoginOut.cs    注销,用于登录注销窗口

Page        文件夹,其他创业所在的目录

------------------------------入口程序----------------------------------

static class Program
    {
        public static Form mainForm = null;
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Login());

if (mainForm != null)
            {
                Application.Run(mainForm);
            }
        }
}

------------------------------------------------------------------
页面跳转
//实例化主画面
Program.mainForm = new MainForm();
//关闭登录画面
this.Close();

---------------------------创建基类---------------------------------------

namespace BiogasProjectClient.Page
{
    partial class BaseForm
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

/// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

#region Windows Form Designer generated code

/// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            //
            // BaseForm
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(702, 337);
            this.Name = "BaseForm";
            this.ResumeLayout(false);

}

#endregion
    }
}
---------------------------webBrowser控件---------------------------------------
1.调用网址
this.webBrowser1.Url = new System.Uri("http://127.0.0.1", System.UriKind.Absolute);

2.禁止右键
this.webBrowser1.IsWebBrowserContextMenuEnabled = false;

---------------------------DockPanel控件显示页面---------------------------------------

SubPage sp = new SubPage();        //子页

//DockPanel显示SubPage页面
//this.dpMain为DockPanel的控件名称
this.sp.Show(this.dpMain, WeifenLuo.WinFormsUI.Docking.DockState.Document);

---------------------------点击弹出新页面---------------------------------------
private void menu_Click(object sender, EventArgs e){
    SubPage sp = new SubPage();
        sp.ShowDialog();    //弹出新页面
}

---------------------------winform程序对文件的文读写操作---------------------------------------
ArrayList LineList = new ArrayList();
LineList.Add("[读写器]");
LineList.Add("固定端口=80");
LineList.Add("(如果需要可设置为01-99)");

try
{
    FileStream fs = new FileStream(System.Environment.CurrentDirectory + "//HL_ICCRW.ini", FileMode.Create, FileAccess.ReadWrite);
    StreamWriter sw = new StreamWriter(fs);

for (int i = 0; i < 3; i++)
    {
        sw.WriteLine(LineList[i]);
    }

sw.Flush();
    sw.Close();
    fs.Close();
    MessageBox.Show("COM端口设置成功!", "COM端口设置", MessageBoxButtons.OK, MessageBoxIcon.Information);
    this.Close();
}
catch (Exception ex)
{
    MessageBox.Show("COM端口设置失败!" + Environment.NewLine + ex.Message, "设置失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
    throw ex;
}

读出文件:

Int16 nCOM = 0;
try
{
    string[] strCOM = File.ReadAllLines(System.Environment.CurrentDirectory + "//HL_ICCRW.ini");
    nCOM = Convert.ToInt16(strCOM[1].Split('=')[1]);
}
catch (Exception ex)
{
    nCOM = 0;
    throw ex;
}

WinForm程序开发的更多相关文章

  1. winform总结5> winform程序开发注意事项

    1.全局异常捕获 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //处理UI线程异常 Ap ...

  2. C# winform 程序开发知识点总结(干货)

    1.数据库连接及操作 在说数据库操作之前,先说一下数据库连接操作字符串的获取 首先,点击服务器资源管理器,接下来选中数据连接右键点击添加连接,填入你要连接的服务器名称,点击单选框使用SQL Serve ...

  3. winForm 程序开发界面参数传递

    1. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; u ...

  4. WinForm界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用

    WinForm界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用 转自:http://www.cnblogs.com/wuhuacong/arch ...

  5. C#软件winform程序安装包制作及卸载程序制作

    使用vs2010 winform程序开发的软件的人比较多,程序的开发是为了在不同的人不同的机器使用,为了使不同的机器能使用该软件就需要在制作程序安装包,安装包里必须包含该软件运行所选的所有环境,下面就 ...

  6. 使用Microsoft.ExceptionMessageBox.dll捕获WinForm程序中异常信息并弹窗显示

    WinForm程序开发中,在开发模式下对于异常的处理一般都是通过调试的方式来查找异常发生的未知与原因. 下面以“除数为0”的情况来具体说明. Button按钮事件如下: private void bu ...

  7. WinForm程序打包工具InnoSetup使用说明图文教程

    WinForm程序打包工具InnoSetup使用说明图文教程 WinForm程序开发测试好了,如果将Debug/Release里面的文件发给客户使用,会让客户觉得你不够专业,但是使用VS自带的打包工具 ...

  8. 基于 SailingEase WinForm Framework 开发客户端程序(3:实现菜单/工具栏按钮的解耦及状态控制)

    本系列文章将详细阐述客户端应用程序的设计理念,实现方法. 本系列文章以  SailingEase WinForm Framework 为基础进行设计并实现,但其中的设计理念及方法,亦适用于任何类型的客 ...

  9. 基于 SailingEase WinForm Framework 开发优秀的客户端应用程序(目录)

    本系统文章将详细阐述客户端应用程序的设计理念,实现方法. 本系列文章以  SailingEase WinForm Framework 为基础进行设计并实现,但其中的设计理念及方法,亦适用于任何类型的客 ...

随机推荐

  1. Win10正式版开机慢怎么办 开机黑屏时间长怎么办

    升级Win10正式版后开机速度慢.黑屏时间长怎么解决呢?其实我重要是由Win10正式版所提供的“快速启动”功能与电脑显卡驱动.电源管理驱动不兼容所造成的.下面就与大家分享一下针对Win10正式版开机速 ...

  2. 在ASP.NET Web API中使用OData的单例模式

    从OData v4开始增加了对单例模式的支持,我们不用每次根据主键等来获取某个EDM,就像在C#中使用单例模式一样.实现方式大致需要两步: 1.在需要实现单例模式的导航属性上加上[Singleton] ...

  3. finger-guessing game:3增加猜拳次数及猜拳按钮显示

    增加猜拳次数及猜拳按钮 //初始化引擎组件 init(50, "div_caiquan", 800, 400, main); //定义游戏层,加载进度层.游戏背景层,结果显示层,出 ...

  4. C#编程(六十一)------------LINQ中的扩展方法

    原文链接: http://blog.csdn.net/shanyongxu/article/details/47208401 LINQ中的扩展方法 LINQ中where扩展方法,要想使用,必须导入us ...

  5. ifeq endif

    ifeq ($(PLATFORM_VERSION),4.4)$(info "________________________4.4"); LOCAL_CFLAGS += -DPLU ...

  6. jquery.timers使用说明

    jQuery Timers提供了三个函式 1. everyTime(时间间隔, [定时器名称], 函式名称, [次数限制], [等待函式程序完成])2. oneTime(时间间隔, [定时器名称],  ...

  7. 第三方包jintellitype实现Java设置全局热键

    Java原生API并不支持为应用程序设置全局热键.要实现全局热键,需要用JNI方式实现,这就涉及到编写C/C++代码,这对于大多数不熟悉C /C++的javaer来说,有点困难.不过幸好,国外有人已经 ...

  8. Material Designer的低版本兼容实现(三)——Color

    在Material Designer中,色彩再一次被摆到了重要的位置上.官方文档中竟然给出了500种配色方案进行选择.就是为了给不同的手机.电视.手表上带来一直的用户体验. 更多用于控制色彩的属性,可 ...

  9. 获取机器的基本参数cat /proc/stat

    获取机器的基本参数cat /proc/stat Note : This guide is applicable to Linux kernels 2.6.14 and above, which add ...

  10. Java 文件路径相关

    不得不说Java的文件路径弄得很复杂, 有编译目录和resource目录什么的和解释型语言(PHP)的就是不一样 搞了好几年java一直没认真去研究这些个破路径怎么回事, 每次都忘记, 梳理一下备忘 ...