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. 移植Python3到TQ2440(一)

    平台 硬件:TQ2440  64MB内存 256MB NandFlash bootloader:U-Boot 2015.04 kernel:linux-4.9 Python: Python-3.6.0 ...

  2. 使用HttpClient对ASP.NET Web API服务实现增删改查

    本篇体验使用HttpClient对ASP.NET Web API服务实现增删改查. 创建ASP.NET Web API项目 新建项目,选择"ASP.NET MVC 4 Web应用程序&quo ...

  3. JPA & Hibernate 注解

    1 . @Entity(name="EntityName") 必须 ,name 为可选 , 对应数据库中一的个表 2 . @Table(name="",cata ...

  4. 【linux c】setsockopt 详解

    转自:http://blog.csdn.net/zhonglinzhang/article/details/9183229 功能描述:        获取或者设置与某个套接字关联的选 项.选项可能存在 ...

  5. Unity3d-Particle System系统的学习(一)

    最近看了下Unity3d的粒子系统的相关视频,并且动手操作了下,感觉自己的美工技能又增进了下(开个小玩笑),发现粒子系统所需要记忆的东西还是有点多的. 所以为了不让自己遗忘某些知识点,我准备发布成博客 ...

  6. 分布式系统唯一ID生成方案汇总 转

    系统唯一ID是我们在设计一个系统的时候常常会遇见的问题,也常常为这个问题而纠结.生成ID的方法有很多,适应不同的场景.需求以及性能要求.所以有些比较复杂的系统会有多个ID生成的策略.下面就介绍一些常见 ...

  7. intellij idea 无法启动或调试 spring-boot

    解决方案一: 原因是因为Working directory没有指定, 并且运行前要手动执行mvn clean install命令才可以.所以导致错误了.希望大家不要犯类似错误. 解决方式二: 看看你的 ...

  8. ImageView和onTouchListener实现,点击查看图片细节

    这是来自疯狂android讲义上的例子,其实没啥意思.就是用监听器获取到手指的坐标,然后根据这个坐标开始绘制一个图片.(这里的绘制方式有些问题,所以凑合看看吧.) 首先,还是布局文件(两个ImageV ...

  9. Spring MVC+Mybatis 多数据源配置

    文章来自:https://www.jianshu.com/p/fddcc1a6b2d8 1. 继承AbstractRoutingDataSource AbstractRoutingDataSource ...

  10. scriptcs简介

    一.scriptcs简介 scriptcs易于编写和执行C #用一个简单的文本编辑器. 在Visual Studio中,和其他的思想,是功能强大的工具,他们有时会阻碍生产力比他们更促进它. 您并不总是 ...