摘要: 方法一:传值最先想到的,Form2构造函数中接收一个string类型参数,即Form1中选中行的文本,将Form2的TextBox控件的Text设置为该string,即完成了Form1向Form2的传值。当Form2的AcceptChange按钮按下,需要修改Form1中ListBox中相应列的值,因此可以考虑同时将Form1中的ListBox控件当参数也传入Form2,所有修改工作都在Form2中完成,根据这个思路,Form2代码如下:public partial class Form2 : Form{private string text;private ListBox lb;privat 阅读全文
posted @ 2012-12-06 15:14 Asa.Zhu 阅读(7280) 评论(0) 推荐(0) 编辑
摘要: #region//开机自动运行 private void CB_Auto_CheckedChanged(object sender, EventArgs e) {//CB_Auto是一个Checkbox,IsAutoRun 是个布尔变量,用于控制是否开机运行 if (CB_Auto.Checked == true) IsAutoRun = true; else IsAutoRun = false; try { AutoRun(); } catch { } } private void AutoRun() { //获取程序执行路径.. string starupPath = Applicati. 阅读全文
posted @ 2012-12-06 15:13 Asa.Zhu 阅读(4137) 评论(1) 推荐(1) 编辑
摘要: (一) 使用动态创建的方法 首先创建 Excel 对象,使用ComObj: var ExcelApp: Variant; ExcelApp := CreateOleObject( 'Excel.Application' ); 1) 显示当前窗口: ExcelApp.Visible := True; 2) 更改 Excel 标题栏: ExcelApp.Caption := '应用程序调用 Microsoft Excel'; 3) 添加新工作簿: ExcelApp.WorkBooks.Add; 4) 打开已存在的工作簿: ExcelApp.WorkBooks.Ope 阅读全文
posted @ 2012-12-06 15:00 Asa.Zhu 阅读(6824) 评论(0) 推荐(0) 编辑
摘要: 1.this.Close(); 只是关闭当前窗口,若不是主窗体的话,是无法退出程序的,另外若有托管线程(非主线程),也无法干净地退出;2.Application.Exit(); 强制所有消息中止,退出所有的窗体,但是若有托管线程(非主线程),也无法干净地退出;3.Application.ExitThread(); 强制中止调用线程上的所有消息,同样面临其它线程无法正确退出的问题;4.System.Environment.Exit(0); 这是最彻底的退出方式,不管什么线程都被强制退出,把程序结束的很干净。 阅读全文
posted @ 2012-12-06 14:59 Asa.Zhu 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 第一种方法:System.Diagnostics.ProcessStartInfo info =new System.Diagnostics.ProcessStartInfo(path);info.WorkingDirectory = Path.GetDirectoryName(path); System.Diagnostics.Process.Start(info); 第二中方法:System.Diagnostics.Process.Start(path)第三种方法:Process p =new Process();p.StartInfo.FileName ="cmd.exe&qu 阅读全文
posted @ 2012-12-06 14:58 Asa.Zhu 阅读(22917) 评论(2) 推荐(2) 编辑
摘要: 读写ini文件using System;using System.Collections.Generic;using System.Text;namespace HYInstall{ class IniFile { // 声明INI文件的写操作函数 WritePrivateProfileString() [System.Runtime.InteropServices.DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, s 阅读全文
posted @ 2012-12-06 14:58 Asa.Zhu 阅读(390) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.IO;using System.Diagnostics;namespace HYInstall{ public partial class Form1 : Form { string Current = Directory.GetC... 阅读全文
posted @ 2012-12-06 14:57 Asa.Zhu 阅读(240) 评论(0) 推荐(0) 编辑
摘要: usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Text.RegularExpressions;usingSystem.Windows.Forms;usingSystem.Net;namespaceWindowsFormsApplication1{publicpartialclassForm1:Form{publicForm1(){Ini 阅读全文
posted @ 2012-12-06 14:55 Asa.Zhu 阅读(305) 评论(0) 推荐(0) 编辑
摘要: Microsoft.VisualBasic.dll 引用using Microsoft.VisualBasic;String PM = Interaction.InputBox("请输入密码", "输入密码", "", 100, 100); if (PM != "123456") { MessageBox.Show("请输入正确的密码谢谢!!!!!"); return; } 阅读全文
posted @ 2012-12-06 14:54 Asa.Zhu 阅读(12532) 评论(1) 推荐(0) 编辑
摘要: private static Form2 f2=null;private static Form3 f3 = null;private void button1_Click(object sender, EventArgs e) { if (f3 != null) { f3.Hide(); } if (f2== null) { f2 = new Form2(); f2.TopLevel = false; f2.Parent = this.panel3; f2.Show(... 阅读全文
posted @ 2012-12-06 14:54 Asa.Zhu 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 记性不好,就写下来。这个问题浪了我不少时间,希望不要再浪费其他人的时间了。1.FrmParent.csprivate void Button1_Click(object sender, EventArgs e) { FrmChild frmChild = new FrmChild(); frmChild .parentFrm = this; frmChild .ShowDialog(); }public void TestFunction(){MessageBox.show("这个是父窗体的函数");}2.FrmChild.csForm parentFrm ;private 阅读全文
posted @ 2012-12-06 14:53 Asa.Zhu 阅读(749) 评论(0) 推荐(0) 编辑
摘要: 本次示例效果如下:Form1为父窗体(包含textBox1、button1)Form2为子窗体(包含textBox2、button2)父窗体给子窗体传值==================1.点击Form1的button1 打开Form2 父窗体给子窗体传值 可以调用重载子窗体的构造函数 直接传入相关数值 public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 frm2 阅读全文
posted @ 2012-12-06 14:53 Asa.Zhu 阅读(377) 评论(0) 推荐(0) 编辑
摘要: RowHeadersVisible = false 阅读全文
posted @ 2012-12-06 14:42 Asa.Zhu 阅读(215) 评论(0) 推荐(0) 编辑
摘要: C#使用udl连接数据库示例1、OleDbConnection oleconn = new OleDbConnection();oleconn.ConnectionString = @"File Name ="+Application.StartupPath+"\chis.udl";OleDbCommand olecommand = new OleDbCommand();olecommand.Connection = oleconn;olecommand.CommandText = "select * from mz_patient_mi&qu 阅读全文
posted @ 2012-12-06 14:28 Asa.Zhu 阅读(2653) 评论(0) 推荐(0) 编辑