//在主窗口中的事件 
 
 
private void 单据管理toolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
this.winPanen.Controls.Clear();
CheckBillForm form = new CheckBillForm();
form.TopLevel = false;
//form.WindowState = FormWindowState.Maximized;
this.winPanen.Controls.Add(form);
form.Location = new Point((this.winPanen.Width - form.Width) / 2, (this.winPanen.Height - form.Height - 100) / 2);
form.Show();
}
catch (Exception ex)
{
Log.AddLog(ex.ToString());
}
}
 
 
/// <summary>
/// 小窗口的位置一直居中
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void WinForm_SizeChanged(object sender, EventArgs e)
{
// -(Screen.PrimaryScreen.Bounds.Height - Screen.PrimaryScreen.WorkingArea.Width);
this.winPanen.Width = this.Width;
this.winPanen.Height = this.Height;
foreach (var control in this.winPanen.Controls)
{
if (control is Form)
{
var f = ((Form)control);
if (this.winPanen.Width > f.Width && this.winPanen.Height > f.Height)
{
f.Location = new Point((this.winPanen.Width - f.Width) / 2, (this.winPanen.Height - f.Height - 100) / 2);
}
}
}
}
 
posted on 2016-09-22 14:28  zishen  阅读(1208)  评论(0编辑  收藏  举报