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();
}
}
在当前按钮位置弹出窗体的代码。自动计算弹出方位。
最新推荐文章于 2020-12-19 23:18:54 发布