資源簡介
c# tabcontrol動態(tài)生成選項卡,并添加窗體

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
namespace?WindowsFormsApplication2
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????for?(int?i?=0;?i?10;?i++)
????????????{
????????????????this.dataGridView1.Rows[i].Cells[0].Value?=?i.ToString();
????????????????int?aa?=?this.dataGridView1.Rows.Add();
????????????}
???????????
???????????
????????}
????????private?void?dataGridView1_CurrentCellDirtyStateChanged(object?sender?EventArgs?e)
????????{
???????????
????????}
????????private?void?dataGridView1_CurrentCellChanged(object?sender?EventArgs?e)
????????{
????????????MessageBox.Show(“a“);
????????}
???????///?
///?窗體距離屏幕邊緣較近的時候貼在屏幕邊緣的函數(shù)
///?
///?窗體控件(一般傳this即可)
///?自定義的與屏幕邊緣的距離
///?是否在屏幕工作區(qū)進行該操作(true表示不包括任務欄false則包括整個屏幕的范圍)
public?void?Form_Welt(Control?form?int?space?bool?isWorkingArea)
{
????//獲取窗體的左上角的xy坐標
????int?x?=?form.Location.X;
????int?y?=?form.Location.Y;
????int?sW?=?0;
????int?sH?=?0;
????if?(isWorkingArea)
????{
????????//獲取屏幕的工作區(qū)(不包括任務欄)的寬度和高度
????????sW?=?Screen.PrimaryScreen.WorkingArea.Width;
????????sH?=?Screen.PrimaryScreen.WorkingArea.Height;
????}
????else
????{
????????//獲取整個屏幕(包括任務欄)的寬度和高度
????????sW?=?Screen.PrimaryScreen.Bounds.Width;
????????sH?=?Screen.PrimaryScreen.Bounds.Height;
????}
????//如果窗體的左邊緣和屏幕左邊緣的距離在用戶定義的范圍內(nèi)則執(zhí)行左貼邊
????if?((x?<=?space?&&?x?>?0)?||?(Math.Abs(x)?<=?space?&&?x?0))??//Math.Abs(x)是取絕對值
????{
????????form.Location?=?new?Point(0?y);
????}
????//如果窗體的上邊緣和屏幕上邊緣的距離在用戶定義的范圍內(nèi)則執(zhí)行上貼邊
????if?((y?<=?space?&&?y?>?0)?||?(Math.Abs(y)?<=?space?&&?y?0))
????{
????????form.Location?=?new?Point(x?0);
????}
????//窗體右邊緣跟屏幕右邊緣的距離
????int?rightW?=?sW?-?form.Right;
????//窗體下邊緣跟屏幕下邊緣的距離
????int?bottomW?=?sH?-?form.Bottom;
????//判斷右邊的情況
????if?((rightW?<=?space?&&?form.Right?????{
????????form.Location?=?new?Point(sW?-?form.Width?y);
????}
????//判斷下邊的情況
????if?((bottomW?<=?10?&&?form.Bottom?????{
????????form.Location?=?new?Point(x?sH?-?form.Height);
????}
}
private?void?Form1_Load(object?sender?EventArgs?e)
{
????Form_Welt(this?5?true);
}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2010-11-07?16:16??WindowsFormsApplication2\
?????目錄???????????0??2010-12-19?00:52??WindowsFormsApplication2\WindowsFormsApplication2\
?????文件?????????962??2010-11-07?16:16??WindowsFormsApplication2\WindowsFormsApplication2.sln
?????文件???????24064??2010-12-19?00:53??WindowsFormsApplication2\WindowsFormsApplication2.suo
?????目錄???????????0??2010-11-07?16:16??WindowsFormsApplication2\WindowsFormsApplication2\bin\
?????目錄???????????0??2010-11-29?22:22??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\
?????文件??????393216??2005-12-08?14:51??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\Microsoft.Data.ConnectionUI.Dialog.dll
?????文件????????6144??2005-12-08?14:51??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\Microsoft.Data.ConnectionUI.dll
?????文件????????6103??2005-12-08?15:46??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\Microsoft.Data.ConnectionUI.xm
?????文件???????15877??2010-11-29?22:21??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\rss01.xm
?????文件???????18944??2010-12-19?00:52??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.exe
?????文件???????48640??2010-12-19?00:52??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.pdb
?????文件???????14328??2010-12-19?00:52??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe
?????文件?????????490??2009-06-11?05:14??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\WindowsFormsApplication2.vshost.exe.manifest
?????目錄???????????0??2010-11-29?21:11??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\zh-CHS\
?????文件??????266240??2005-12-13?17:55??WindowsFormsApplication2\WindowsFormsApplication2\bin\Debug\zh-CHS\Microsoft.Data.ConnectionUI.Dialog.resources.dll
?????文件????????3129??2010-11-18?20:08??WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs
?????文件????????3677??2010-11-18?20:08??WindowsFormsApplication2\WindowsFormsApplication2\Form1.Designer.cs
?????文件????????5998??2010-11-18?20:08??WindowsFormsApplication2\WindowsFormsApplication2\Form1.resx
?????文件????????2021??2010-11-29?22:09??WindowsFormsApplication2\WindowsFormsApplication2\Form2.cs
?????文件????????3262??2010-11-29?22:08??WindowsFormsApplication2\WindowsFormsApplication2\Form2.Designer.cs
?????文件????????5814??2010-11-29?22:08??WindowsFormsApplication2\WindowsFormsApplication2\Form2.resx
?????文件????????1499??2010-11-29?23:04??WindowsFormsApplication2\WindowsFormsApplication2\Form3.cs
?????文件????????2592??2010-11-29?22:55??WindowsFormsApplication2\WindowsFormsApplication2\Form3.Designer.cs
?????文件????????5814??2010-11-29?22:55??WindowsFormsApplication2\WindowsFormsApplication2\Form3.resx
?????文件?????????925??2010-12-09?18:13??WindowsFormsApplication2\WindowsFormsApplication2\Form4.cs
?????文件????????2049??2010-12-09?18:11??WindowsFormsApplication2\WindowsFormsApplication2\Form4.Designer.cs
?????文件????????5814??2010-12-09?18:11??WindowsFormsApplication2\WindowsFormsApplication2\Form4.resx
?????文件????????3471??2010-12-19?00:52??WindowsFormsApplication2\WindowsFormsApplication2\Form5.cs
?????文件????????3971??2010-12-19?00:52??WindowsFormsApplication2\WindowsFormsApplication2\Form5.Designer.cs
?????文件????????5814??2010-12-19?00:50??WindowsFormsApplication2\WindowsFormsApplication2\Form5.resx
............此處省略26個文件信息
- 上一篇:C#開發(fā)之洪水淹沒
- 下一篇:.net winform自動升級
評論
共有 條評論