预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共41页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

控件和对话框设计Windows程序设计一般步骤对话框Dialog属性事件//Callthismethodfromtheconstructorofyourform privatevoidOtherInitialize(){ this.Closing+=newCancelEventHandler(this.Form1_Closing); //Exchangecommentedlineandnotethedifference. this.isDataSaved=true; //this.isDataSaved=false; } privatevoidForm1_Closing(Objectsender,CancelEventArgse){ if(!isDataSaved){ e.Cancel=true; MessageBox.Show("Youmustsavefirst."); } else{ e.Cancel=false; MessageBox.Show("Goodbye."); } } 方法Label控件Button控件TextBox控件ListBox控件常用事件 DoubleClick SelectedIndexChanged 常用方法 ClearSelected SetSelectedItems集合 常用属性: Count 常用方法: Add RemoveAt Insert Clear ComboBoxRadioButton控件CheckBox控件PictureBox控件GroupBox控件PanelTimer控件其他常用控件对话框返回值DialogResult枚举Button的DialogResult属性Form的DialogResult属性常用对话框MessageBoxMessageBoxButtons枚举MessageBoxIcon枚举通用对话框ColorDialogprivatevoidbutton1_Click(objectsender,System.EventArgse) { ColorDialogMyDialog=newColorDialog(); //Keepstheuserfromselectingacustomcolor. MyDialog.AllowFullOpen=false; //Allowstheusertogethelp.(Thedefaultisfalse.) MyDialog.ShowHelp=true; //Setstheinitialcolorselecttothecurrenttextcolor. MyDialog.Color=textBox1.ForeColor; //UpdatethetextboxcoloriftheuserclicksOK if(MyDialog.ShowDialog()==DialogResult.OK) textBox1.ForeColor=MyDialog.Color; } FontDialogprivatevoidbutton1_Click(objectsender,System.EventArgse) { FontDialogfontDialog1=newFontDialog(); fontDialog1.ShowColor=true; fontDialog1.Font=textBox1.Font; fontDialog1.Color=textBox1.ForeColor; if(fontDialog1.ShowDialog()!=DialogResult.Cancel) { textBox1.Font=fontDialog1.Font; textBox1.ForeColor=fontDialog1.Color; } } OpenFileDialogprivatevoidbutton1_Click(objectsender,System.EventArgse) { OpenFileDialogopenFileDialog1=newOpenFileDialog(); openFileDialog1.InitialDirectory="c:\\"; openFileDialog1.Filter="txtfiles(*.txt)|*.txt|Allfiles(*.*)|*.*"; openFileDialog1.FilterIndex=2; openFileDialog1.RestoreDirectory=true; if(openFileDialog1.ShowDialog()==DialogResult.OK) { } } SaveFileDialogprivatevoidButton1_Click(System.Objectse