资源简介
c# tabcontrol动态生成选项卡,并添加窗体
代码片段和文件信息
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“);
}
///
/// 窗体距离屏幕边缘较近的时候贴在屏幕边缘的函数
///
/// 窗体控件(一般传this即可)
/// 自定义的与屏幕边缘的距离
/// 是否在屏幕工作区进行该操作(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)
{
//获取屏幕的工作区(不包括任务栏)的宽度和高度
sW = Screen.PrimaryScreen.WorkingArea.Width;
sH = Screen.PrimaryScreen.WorkingArea.Height;
}
else
{
//获取整个屏幕(包括任务栏)的宽度和高度
sW = Screen.PrimaryScreen.Bounds.Width;
sH = Screen.PrimaryScreen.Bounds.Height;
}
//如果窗体的左边缘和屏幕左边缘的距离在用户定义的范围内则执行左贴边
if ((x <= space && x > 0) || (Math.Abs(x) <= space && x < 0)) //Math.Abs(x)是取绝对值
{
form.Location = new Point(0 y);
}
//如果窗体的上边缘和屏幕上边缘的距离在用户定义的范围内则执行上贴边
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 < sW) || (Math.Abs(rightW) <= space && rightW < 0))
{
form.Location = new Point(sW - form.Width y);
}
//判断下边的情况
if ((bottomW <= 10 && form.Bottom < sH) || (Math.Abs(bottomW) <= space && bottomW < 0))
{
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#开发之洪水淹没
- 下一篇:.net winform自动升级
评论
共有 条评论