在当前按钮位置弹出窗体的代码。自动计算弹出方位。
2009-07-23 09:29
483 查看
private void button_Click(object sender, System.EventArgs e)
{
string data = "data"
Form f = new Form();
try
{
int topx = this.Parent.PointToScreen(this.Location).X;
int topy = this.Parent.PointToScreen(this.Location).Y;
int bottomx = topx + this.Width;
int bottomy = topy + this.Height;
if (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - topx >= f.Width)
f.Left = topx;
else
f.Left = bottomx - f.Width;
if (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - bottomy >= f.Height)
f.Top = bottomy;
else
f.Top = topy - f.Height;
f.Data = data;
if (f.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
{
}
}
catch (Exception ex)
{
throw new Exception(this.Name,ex);
}
finally
{
f.Dispose();
}
}
{
string data = "data"
Form f = new Form();
try
{
int topx = this.Parent.PointToScreen(this.Location).X;
int topy = this.Parent.PointToScreen(this.Location).Y;
int bottomx = topx + this.Width;
int bottomy = topy + this.Height;
if (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - topx >= f.Width)
f.Left = topx;
else
f.Left = bottomx - f.Width;
if (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - bottomy >= f.Height)
f.Top = bottomy;
else
f.Top = topy - f.Height;
f.Data = data;
if (f.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
{
}
}
catch (Exception ex)
{
throw new Exception(this.Name,ex);
}
finally
{
f.Dispose();
}
}
相关文章推荐
- VS 自动展开选中当前代码所在的文件位置的功能
- winform 点击按钮,弹出窗体,弹出窗体的位置在按钮的下方
- jquery实现可自动判断位置的弹出层效果代码
- 设计一个如下图所示窗体:该窗体自动位于屏幕中央;大小不可调;最小化、最大化按钮不可用;窗体标题为“烟台大学”。在该窗体上,放置一个按钮、一个标签。单击按钮时,在标签上显示当前系统时间。
- .NET中用弹出窗口添加或修改一个页面,当添加或修改相关内容后按下提交按钮自动刷新页面的JS代码
- Code::Blocks代码自动提示设置及常用快捷键(适用windows和linux) 1)以下需要设置的地方均在Settings->Editor...弹出的对话框中。 2)不少命令都可针对当前行或
- 查询Microsoft Visual C++ Debug Library窗体并自动点击忽略按钮的小工具代码
- 方便的弹出视图,可随意定义箭头方向,自动计算位置
- 上述代码是A对话框中“确定”按钮,在调用C对话框之前要先要自动弹出B对话框,怎么办?
- jquery实现可自动判断位置的弹出层效果代码
- 完美仿MSN右下角弹出广告代码并可自动消失,附带关闭按钮
- vs2010自动展开选中当前代码所在的文件位置的功能
- jquery弹出层代码,自动判断位置
- c# 弹出窗体选择文件代码
- 点击文字弹出一个DIV层窗口代码 【或FORM表单 并且获取点击按钮的ID值】
- Asp.net 2.0 自定义控件开发[实现自动计算功能(AutoComputeControl)][示例代码下载]
- 如何将当前界面的可视组件以同样的相对位置和大小保存在png图像文件中?要求写出实践的代码。
- jQuery弹出Div窗口居中显示、滚动跟随、关闭按钮以及几秒后自动消失
- c#在当前窗体的按钮事件调用另一封…
- Asp.net 2.0 自定义控件开发[实现自动计算功能(AutoComputeControl)][示例代码下载][续]