WinForm程序开发
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程序开发的更多相关文章
- winform总结5> winform程序开发注意事项
1.全局异常捕获 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //处理UI线程异常 Ap ...
- C# winform 程序开发知识点总结(干货)
1.数据库连接及操作 在说数据库操作之前,先说一下数据库连接操作字符串的获取 首先,点击服务器资源管理器,接下来选中数据连接右键点击添加连接,填入你要连接的服务器名称,点击单选框使用SQL Serve ...
- winForm 程序开发界面参数传递
1. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; u ...
- WinForm界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用
WinForm界面开发之布局控件"WeifenLuo.WinFormsUI.Docking"的使用 转自:http://www.cnblogs.com/wuhuacong/arch ...
- C#软件winform程序安装包制作及卸载程序制作
使用vs2010 winform程序开发的软件的人比较多,程序的开发是为了在不同的人不同的机器使用,为了使不同的机器能使用该软件就需要在制作程序安装包,安装包里必须包含该软件运行所选的所有环境,下面就 ...
- 使用Microsoft.ExceptionMessageBox.dll捕获WinForm程序中异常信息并弹窗显示
WinForm程序开发中,在开发模式下对于异常的处理一般都是通过调试的方式来查找异常发生的未知与原因. 下面以“除数为0”的情况来具体说明. Button按钮事件如下: private void bu ...
- WinForm程序打包工具InnoSetup使用说明图文教程
WinForm程序打包工具InnoSetup使用说明图文教程 WinForm程序开发测试好了,如果将Debug/Release里面的文件发给客户使用,会让客户觉得你不够专业,但是使用VS自带的打包工具 ...
- 基于 SailingEase WinForm Framework 开发客户端程序(3:实现菜单/工具栏按钮的解耦及状态控制)
本系列文章将详细阐述客户端应用程序的设计理念,实现方法. 本系列文章以 SailingEase WinForm Framework 为基础进行设计并实现,但其中的设计理念及方法,亦适用于任何类型的客 ...
- 基于 SailingEase WinForm Framework 开发优秀的客户端应用程序(目录)
本系统文章将详细阐述客户端应用程序的设计理念,实现方法. 本系列文章以 SailingEase WinForm Framework 为基础进行设计并实现,但其中的设计理念及方法,亦适用于任何类型的客 ...
随机推荐
- 前端使用AngularJS的$resource,后端ASP.NET Web API,实现分页、过滤
在上一篇中实现了增删改查,本篇实现分页和过滤. 本系列包括: 1.前端使用AngularJS的$resource,后端ASP.NET Web API,实现增删改查2.前端使用AngularJS的$re ...
- Android中的"Unable to start activity ComponentInfo"错误
在调试的过程中发现一直报这个错误"Unable to start activity ComponentInfo",从字面的意思看是无法启动某个activity组件,但是看了mani ...
- 集合框架的类和接口均在java.util包中。 任何对象加入集合类后,自动转变为Object类型,所以在取出的时候,需要进行强制类型转换。
集合框架的类和接口均在java.util包中. 任何对象加入集合类后,自动转变为Object类型,所以在取出的时候,需要进行强制类型转换.
- 【推荐】腾讯android镜像(做Android开发的得好好利用下这个网站,国内的大公司还是可以滴……)
原文地址:http://android-mirror.bugly.qq.com:8080/include/usage.html ☀ Windows I. Open Android SDK Manage ...
- Java 数组的 12 个最佳方法
1. 声明一个数组 String[] aArray = new String[5]; String[] bArray = {"a","b","c&q ...
- Java 公历转农历,然后农历减一年(或者几天或者任意天),再把这个日期转成公历
由于系统的提醒有可能是农历的今天或指定时间要用quartz 实现定时任务 公历转农历,然后农历减一年(或者几天或者任意天),再把这个日期转成公历. 网上很多农历转公历的程序都有问题,QQ.百度的也有 ...
- ExtJS 4.2 教程-08:布局系统详解
ExtJS 4.2 系列教程导航目录: ExtJS 4.2 教程-01:Hello ExtJS ExtJS 4.2 教程-02:bootstrap.js 工作方式 ExtJS 4.2 教程-03:使用 ...
- SearchView的最简单的使用方式
SearchView顾名思义就是一个搜索视图,和之前讲解的自动匹配的输入框类似.只不过他有自己特有的监听器,并且可以实时得到用户输入的结果.对于SearchView这个控件,我强烈建议将其放在Acti ...
- [Android Security] DEX文件格式分析
copy from : https://segmentfault.com/a/1190000007652937 0x00 前言 分析 dex 文件格式最好的方式是找个介绍文档,自己再写一个简单的 de ...
- 如何进行Logstash logstash-input-jdbc插件的离线安装
我们单位的服务器位于隔离区,不允许链接互联网,因此整理了在ELK集群上离线安装Logstash的jdbc input插件的方法,供大家参考. 总体思路是需要一台中转的机器,这台机器需要能够访问互联网, ...