zoukankan      html  css  js  c++  java
  • Winform窗口弹出位置控制

    窗体的弹出位置可以由属性StartPosition来指定,默认值有:

    Manural  自定义,由属性Location指定;

    CenterScreen  屏幕中央;

    WindowsDefaultBounds   系统默认位置(但大小为系统默认窗体大小)

    WindowsDefaultLocation  系统默认位置(大小由属性Size指定)

    CenterParent  父窗体中央

    若自定义窗体显示位置,则属性StartPosition选择Manural,然后指定属性Location的坐标值。

    指定窗体显示位置的代码:

    this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
    this.Location = new System.Drawing.Point(100,100);

    实现窗体在屏幕右下角显示:

    经常看到有的软件在屏幕右下角弹出消息窗,用下面的代码可以简单实现:

    public Form1()
    {
        InitializeComponent();
      
      this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
    //获取当前工作区宽度和高度(工作区不包含状态栏) int ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width; int ScreenHeight = Screen.PrimaryScreen.WorkingArea.Height; //计算窗体显示的坐标值,可以根据需要微调几个像素 int x = ScreenWidth - this.Width - 5; int y = ScreenHeight - this.Height - 5;
    this.Location = new Point(x,y); }

    运行结果:

    来源:http://www.cnblogs.com/libaoheng/archive/2011/07/20/2112032.html

     
  • 相关阅读:
    阅读进度条的实现
    获取radio选中的值
    Vue的学习(六)
    Vue的学习(三)
    C#委托详解
    C#泛型和非泛型
    C#装箱和拆箱
    C#内存泄漏的事例
    C#windows服务开发(一)
    C#windows服务开发
  • 原文地址:https://www.cnblogs.com/zeroLove/p/3904241.html
Copyright © 2011-2022 走看看