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 为基础进行设计并实现,但其中的设计理念及方法,亦适用于任何类型的客 ...
随机推荐
- 利用npm 安装删除模块
转自 涵一原文 利用npm 安装删除模块 1. npm安装模块 [npm install xxx]利用 npm 安装xxx模块到当前命令行所在目录:[npm install -g xxx]利用npm安 ...
- Xcode工程文件打不开:cannot be opened because the project file cannot be parsed
svn更新代码后,打开xcode工程文件,会出现 xxx..xcodeproj cannot be opened because the project file cannot be parsed ...
- iOS开发25:使用SOAP访问Web服务
SOAP是简单对象访问协议,它可看成是HTTP与XML的结合,其中XML部分是作为HTTP报文的实体主体部分.具体信息可以参考百度百科. 在iOS中使用SOAP,需要我们自己组装XML格式的字符串,当 ...
- java 解压zip java.lang.IllegalArgumentException: MALFORMED 错误
ava.lang.IllegalArgumentException: MALFORMED at java.util.zip.ZipCoder.toString(Unknown Source) at j ...
- 寂静之地百度云在线观看迅雷下载A Quiet Place高清BT下载
原名:A Quiet Place 地区:美国 语言:英语 / 美国手语 首播:2018-05-18(中国大陆) / 2018-03-09(西南偏南电影节) / 2018-04-06(美国) 电视台 ...
- putty adb
putty.exe -adb -P 5037 transport-usb 网络调试也是可以的 先connect 再执行上面的命令 http://files.cnblogs.com/files/ahuo ...
- 自定义各式各样的圆形ProgressBar
上面三个图分别是 开始时的样子,走进度时候的样子,最后完成的样子 这是我在两个大神的Demo基础上修改后的结果,我们先来看看自定义view是怎么做到的. 1.自己写一个类继承View类,然后 ...
- Jenkins 快速搭建
Jenkins 介绍 Jenkins 作为持续集成的重要工具,在DevOps整个工具链中有重要的地位.Jenkins 一般作为独立的应用运行在Java Servlet容器中如Jetty,也可以运行在其 ...
- COUNT DISTINCT ROW_NUMBER DENSE_RANK 以及对COUNT去重(非PARTITION)
1:COUNT DISTINCT SELECT COUNT(DISTINCT [QS_QuestionStem].Id) AS ReqCount1, ...
- 在 Linux 下用 CMAKE 编译安装 OpenCV 3.2.0
[安装相关软件和库] 1.安装CMAKE:这里使用apt-get来安装; CMAKE 是一个跨平台编译工具,能够输出各种makefile,和project 文件,指导编译器编译,对CMAKE具体的可以 ...