C#winform零碎常识
列表框获取当前选中项
comboBox1.SelectedItem
//设置列表框不能自己编辑
在属性列表中设置:DropDownStyle 设置为:dropdownlist
状态栏修改strint属性可以让他显示在最右侧
//设置DataGridView的表宽度
DataGridView.Columns[0].Width=;
using System Diagnostics 命名空间中的Process类可以启用其他外部程序 例如windows这种的记事本计算机等
privat void 计算器ToolStripMenuItem_Click(object
sender,EventArgs e)
{
System.Diagnostics.Process.Start("calc.exe");
}
配置文件操作
正则表达式命名空间
using System.Text.RegularExpressions;
获取焦点
XXX.Focus();
远程链接数据库
string str = "server=10.10.1.4;database=Student_information_base;uid=sa;pwd=123456;integrated Security=false";
设置配置管理器启用TCP/IP协议
//delegate实现两个窗体传值
Form1中声明一个方法
void show(string str)
{
}
在Form1中实例化Form2的时候传一个方法
Form2 frm2=new Form2(show);
frm2.show();
Form2声明委托
public Delegate void DelTest(string str)
//在Form2中声明一个委托字段
public DelTest _del;
public Form2(DelTest del)
{
this._del=del;
}
//在按钮中写
_del(textBox1.Text)
//实现先不显示主窗体
//在program中写
//实例化要显示的窗体
Form2 f2=new Form();
f2.showdialog();
if(f2.DialoResult==DialoResult.Ok)
{
Application.Run(new Form1());
}
//之后在f2中设置
this.DialogResult=DialogResult.OK;
状态栏修改strint属性可以让他显示在最右侧
//设置DataGridView的表宽度
DataGridView.Columns[0].Width=;
wimform显示异常信息
try
{
}
catch(Exception e)
{
MessageBox.Show(e.Message.ToString());
}
7.#region与#endregion
前台线程:只有所有的前台线程都关闭完成程序才能关闭
后台线程:只要所有的前台线程结束,后台线程自动结束
设置为后台线程 XX.Isbackground=true;
终止线程:Abort();
/
线程
using System Therading
Therad xh=new Thread(delegate(){new Form2().ShowDialog();})
xh.Start();
前台线程:只有所有的前台线程都关闭完成程序才能关闭
后台线程:只要所有的前台线程结束,后台线程自动结束
设置为后台线程 XX.Isbackground=true;
终止线程:Abort();
列表框获取当前选中项
comboBox1.SelectedItem
//设置列表框不能自己编辑
在属性列表中设置:DropDownStyle 设置为:dropdownlist
状态栏修改strint属性可以让他显示在最右侧
//设置DataGridView的表宽度
DataGridView.Columns[0].Width=;
using System Diagnostics 命名空间中的Process类可以启用其他外部程序 例如windows这种的记事本计算机等
privat void 计算器ToolStripMenuItem_Click(object
sender,EventArgs e)
{
System.Diagnostics.Process.Start("calc.exe");
}
配置文件操作
正则表达式命名空间
using System.Text.RegularExpressions;
获取焦点
XXX.Focus();
远程链接数据库
string str = "server=10.10.1.4;database=Student_information_base;uid=sa;pwd=123456;integrated Security=false";
设置配置管理器启用TCP/IP协议
//delegate实现两个窗体传值
Form1中声明一个方法
void show(string str)
{
}
在Form1中实例化Form2的时候传一个方法
Form2 frm2=new Form2(show);
frm2.show();
Form2声明委托
public Delegate void DelTest(string str)
//在Form2中声明一个委托字段
public DelTest _del;
public Form2(DelTest del)
{
this._del=del;
}
//在按钮中写
_del(textBox1.Text)
//实现先不显示主窗体
//在program中写
//实例化要显示的窗体
Form2 f2=new Form();
f2.showdialog();
if(f2.DialoResult==DialoResult.Ok)
{
Application.Run(new Form1());
}
//之后在f2中设置
this.DialogResult=DialogResult.OK;
状态栏修改strint属性可以让他显示在最右侧
//设置DataGridView的表宽度
DataGridView.Columns[0].Width=;
wimform显示异常信息
try
{
}
catch(Exception e)
{
MessageBox.Show(e.Message.ToString());
}
7.#region与#endregion
前台线程:只有所有的前台线程都关闭完成程序才能关闭
后台线程:只要所有的前台线程结束,后台线程自动结束
设置为后台线程 XX.Isbackground=true;
终止线程:Abort();
/
线程
using System Therading
Therad xh=new Thread(delegate(){new Form2().ShowDialog();})
xh.Start();
前台线程:只有所有的前台线程都关闭完成程序才能关闭
后台线程:只要所有的前台线程结束,后台线程自动结束
设置为后台线程 XX.Isbackground=true;
终止线程:Abort();
列表框获取当前选中项
comboBox1.SelectedItem
//设置列表框不能自己编辑
在属性列表中设置:DropDownStyle 设置为:dropdownlist
状态栏修改strint属性可以让他显示在最右侧
//设置DataGridView的表宽度
DataGridView.Columns[0].Width=;
using System Diagnostics 命名空间中的Process类可以启用其他外部程序 例如windows这种的记事本计算机等
privat void 计算器ToolStripMenuItem_Click(object
sender,EventArgs e)
{
System.Diagnostics.Process.Start("calc.exe");
}
配置文件操作
正则表达式命名空间
using System.Text.RegularExpressions;
获取焦点
XXX.Focus();
远程链接数据库
string str = "server=10.10.1.4;database=Student_information_base;uid=sa;pwd=123456;integrated Security=false";
设置配置管理器启用TCP/IP协议
//delegate实现两个窗体传值
Form1中声明一个方法
void show(string str)
{
}
在Form1中实例化Form2的时候传一个方法
Form2 frm2=new Form2(show);
frm2.show();
Form2声明委托
public Delegate void DelTest(string str)
//在Form2中声明一个委托字段
public DelTest _del;
public Form2(DelTest del)
{
this._del=del;
}
//在按钮中写
_del(textBox1.Text)
//实现先不显示主窗体
//在program中写
//实例化要显示的窗体
Form2 f2=new Form();
f2.showdialog();
if(f2.DialoResult==DialoResult.Ok)
{
Application.Run(new Form1());
}
//之后在f2中设置
this.DialogResult=DialogResult.OK;
状态栏修改strint属性可以让他显示在最右侧
//设置DataGridView的表宽度
DataGridView.Columns[0].Width=;
wimform显示异常信息
try
{
}
catch(Exception e)
{
MessageBox.Show(e.Message.ToString());
}
7.#region与#endregion
前台线程:只有所有的前台线程都关闭完成程序才能关闭
后台线程:只要所有的前台线程结束,后台线程自动结束
设置为后台线程 XX.Isbackground=true;
终止线程:Abort();
/
线程
using System Therading
Therad xh=new Thread(delegate(){new Form2().ShowDialog();})
xh.Start();
前台线程:只有所有的前台线程都关闭完成程序才能关闭
后台线程:只要所有的前台线程结束,后台线程自动结束
设置为后台线程 XX.Isbackground=true;
终止线程:Abort();
浙公网安备 33010602011771号