我每次运行项目时,我都希望所有表格在同一个地方组合的不同地方? [英] Every Time I Run The Project The Forms On Scean Are Appare Diffrent Places I Want That All Forms Are Combine In Same Place ?

查看:62
本文介绍了我每次运行项目时,我都希望所有表格在同一个地方组合的不同地方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用System;

使用System.Collections.Generic;

使用System.ComponentModel;

使用System.Data;

使用System.Drawing;

使用System.Linq;

使用System.Text;

使用System.Threading.Tasks ;

使用System.Windows.Forms;



命名空间WindowsFormsApplication1

{

公共部分类别选择:表格

{

公共选择()

{

InitializeComponent(); < br $>
}



private void button1_Click(object sender,EventArgs e)

{

ADD sho = new ADD();







sho.Show();

}



private void button5_Click(object sender,EventArgs e)

{

searchothr sho = new searchothr();



//this.Hide();



sho.Show();

}



private void button2_Click(object sender,EventArgs e)

{

CONTECTINFO sho = new CONTECTINFO();



// this.Hide();



sho.Show();

}



private void button3_Click(object sender,EventArgs e)

{

caseinfo sho = new caseinfo ();



// this.Hide();



sho.Show(); < br $>
}



private void button4_Click(object sender,EventArgs e)

{

timer1.Start();

//if(timer1.Stop

// MessageBox.Show(谢谢你使用);



timer1.Stop();

Appli cation.Exit();

}



private void timer1_Tick(object sender,EventArgs e)

{

label1.Text = DateTime.Now.ToString(hh:mm:ss tt);

}



private void button6_Click(object sender,EventArgs e)

{

update sho = new update();



//this.Hide();



sho.Show();

}



private void button7_Click(object sender,EventArgs e)

{

remove sho = new remove();



// this.Hide();



sho.Show();

} < br $>


private void button8_Click(object sender,EventArgs e)

{

// button8 = DateTime.Now。 ToString();

}



private void label1_Click(object sender,EventArgs e)

{



}



private void opption_Load(object sender,EventArgs e)

{

label2.Text = DateTime.Now.ToString(d / MM / yyyy);

label1.Text = DateTime.Now.ToString(hh:mm:ss tt);

//label1.Text=DateTime.Now,ToString(\"dd// mm // yyyy);

timer1.Start();

}

}

}

解决方案

hi使用

 sho.StartPosition = FormStartPosition.CenterScreen; 

或FormStartPosition枚举的任何其他选项



请参阅此链接了解更多详情



https:// msdn.microsoft.com/en-us/library/system.windows.forms.formstartposition%28v=vs.110%29.aspx [ ^ ]


< blockquote>如果表单是无模式的,那么除非确保一次只显示一个表单,否则不希望它们出现在同一个地方。在这种情况下,如果所有表单的大小相同,那么您可以保存位置并在显示任何这些表单时使用该位置。



解决方案1是另一个替代但我不建议用于无模式表格。



如果一次显示多个表格或每个表格都有自己的大小,那么我建议记住每个表单的位置,并保存每个表单的用户设置中的位置。第一次,让用户定位它们。



请注意,如果用户更改其分辨率或断开辅助屏幕,默认位置可能比显示在一个不可见的位置。您可以添加测试以检查矩形是否可见,如果不是,则使用默认位置。


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class opption : Form
{
public opption()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
ADD sho = new ADD();



sho.Show();
}

private void button5_Click(object sender, EventArgs e)
{
searchothr sho = new searchothr();

//this.Hide();

sho.Show();
}

private void button2_Click(object sender, EventArgs e)
{
CONTECTINFO sho = new CONTECTINFO();

// this.Hide();

sho.Show();
}

private void button3_Click(object sender, EventArgs e)
{
caseinfo sho = new caseinfo();

// this.Hide();

sho.Show();
}

private void button4_Click(object sender, EventArgs e)
{
timer1.Start();
//if(timer1.Stop
// MessageBox.Show("THANK YOU FOR USING ");

timer1.Stop ();
Application.Exit();
}

private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString("hh:mm:ss tt");
}

private void button6_Click(object sender, EventArgs e)
{
update sho = new update();

//this.Hide();

sho.Show();
}

private void button7_Click(object sender, EventArgs e)
{
remove sho = new remove();

// this.Hide();

sho.Show();
}

private void button8_Click(object sender, EventArgs e)
{
//button8= DateTime.Now.ToString();
}

private void label1_Click(object sender, EventArgs e)
{

}

private void opption_Load(object sender, EventArgs e)
{
label2.Text=DateTime.Now.ToString("d/MM/yyyy");
label1.Text = DateTime.Now.ToString("hh:mm:ss tt");
//label1.Text=DateTime.Now,ToString("dd//mm//yyyy");
timer1.Start();
}
}
}

解决方案

hi Use

sho.StartPosition = FormStartPosition.CenterScreen;

or any other options from FormStartPosition enum

refer this link for further details

https://msdn.microsoft.com/en-us/library/system.windows.forms.formstartposition%28v=vs.110%29.aspx[^]


If forms are modeless, then you don't want them to appears at the same place except if you ensure that only a single form is displayed at a time. In that case, if all forms are the same size, then you can save the location and use that location when any of these forms are displayed.

Solution 1 is another alternative but I would not recommand it for modeless forms.

If multiple forms are displayed at a time or each one have its own size, then I would suggest to remember the position of each forms and save the position in user settings for each one. The first time, you let the user position them.

Be aware that if the user change its resolution or disconnect a secondary screen, default positionning might be better than displaying at a non visible location. You might add a test to check if the rectangle is visible and if not let Windows use default position.


这篇关于我每次运行项目时,我都希望所有表格在同一个地方组合的不同地方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆