C#winform零碎常识

C#winform零碎常识列表框获取当前选中项comboBox1.SelectedItem//设置列表框不能自己编辑在属性列表中设置:DropDownStyle设置为:dropdownlist状态栏修改strint属性可以让他显示在最右侧//设置DataGridView的表宽度DataGridView.Colu

大家好,欢迎来到IT知识分享网。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();

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/33401.html

(0)
上一篇 2023-12-13 14:15
下一篇 2023-12-14 10:45

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

关注微信