在C#中运行时发布表单 [英] Positing A Form at run time in C#

查看:125
本文介绍了在C#中运行时发布表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我被要求将一张表格放在屏幕中央。我过去曾经使用过这个位置(当时回到VB6用来了解表格会出现在哪里,哇我想念VB6的东西!)但是我觉得这个程序会用在很多东西上(网书,(不寒而栗!)平板电脑)。它只是环顾四周我找到了表格和控制位置和尺寸实用程序 [ ^ ]这似乎对我所追求的内容有点过深。



抱歉

格伦,

啊我发现 Windows窗体 - 创建和加载主窗口窗口形式和子控制状态使用C# [ ^ ]这将给出我想要的东西!

Hi All,

I have been asked to position a Form in the center of the screen. I have in the past used the Location for this (back in the day VB6 used to have a picture of where the form would appear, wow something I miss about VB6!) but I think this program is going to be used on many things (Net books, (shudder!) Tablets). It just in looking around I have found Form and Control Position and Size Utility[^] which seems a little too indepth for what I am after.

Sorry
Glenn,
Ah I have found Windows Forms - Creating and Loading the Main Window Form and Child Control States Using C#[^] will this give what I am looking for!

推荐答案

试试这个:

Try this:
form.Location = new Point((Screen.PrimaryScreen.Bounds.Size.Width / 2) - (form.Size.Width / 2), (Screen.PrimaryScreen.Bounds.Size.Height / 2) - (form.Size.Height / 2)); 


您好。



如果您使用的是Windows窗体......



您可以直接从设计师或通过代码设置StartPosition属性,就在显示之前。



Hi.

If you are working with Windows Forms...

You can set StartPosition property directly from designer or through code, just before showing it.

form.StartPosition = FormStartPosition.CenterScreen;





可能的值是:

手册

CenterScreen

WindowsDefaultLocation

WindowsDefaultBounds

CenterParent



Form.StartPosition Property

FormStartPosition枚举



Daniele。



Possible values are:
Manual
CenterScreen
WindowsDefaultLocation
WindowsDefaultBounds
CenterParent

Form.StartPosition Property
FormStartPosition Enumeration

Daniele.


或者您可以使用表单设计器中的工具,名为Start Position,我很抱歉浪费时间。回到家看看Visual Studio并发誓!
Or you could use the tool in the Form designer, called Start Position, I am sorry for wasting time. Just got home looked at Visual Studio and swore!


这篇关于在C#中运行时发布表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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