右侧打开的窗口表格 [英] Open window form on right side

查看:67
本文介绍了右侧打开的窗口表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打开屏幕右侧的表单显示.按下按钮时如何将其带到顶部,从顶部到底部全尺寸或略微不太可接受....

任何机构都可以帮助我...解决此问题..

I need to open a form display on right side of screen. On pressing a button how to bring it and from top to bottom full size or little less acceptable....

Can any body help me...to solve this issue..

推荐答案

对以下代码进行一些调整.

Do some adjustments on the following code.

private void OpenForm(Form form)
  {
      PositionReporterEdge(form);
      form.Show();
  }

  /// <summary>
  /// Position the "Reporter" form next to the current form.
  /// </summary>
  private void PositionReporterEdge(Form form)
  {
      int screenHeight = Screen.PrimaryScreen.WorkingArea.Height;
      int screenWidth = Screen.PrimaryScreen.WorkingArea.Width;

      Point parentPoint = this.Location;

      int parentHeight = this.Height;
      int parentWidth = this.Width;

      int childHeight = form.Height;
      int childWidth = form.Width;

      int resultX;
      int resultY;

      if ((parentPoint.Y + parentHeight + childHeight) > screenHeight)
      {
          // If we would move off the screen, position near the top.
          resultY = parentPoint.Y + 100; // move down 50
          resultX = parentPoint.X + 50;
      }
      else
      {
          // Position on the edge.
          resultY = parentPoint.Y + parentHeight;
          resultX = parentPoint.X;
      }

      // set our child form to the new position
      form.Location = new Point(resultX, resultY);
  }


只需浏览form的属性,选择form并按f4,以查看在那里的属性,即可找到要设置的位置...
just explore properties of form , select form and press f4, to see properties there u can find position to set...


这篇关于右侧打开的窗口表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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