• <tfoot id='xFYro'></tfoot>
    <legend id='xFYro'><style id='xFYro'><dir id='xFYro'><q id='xFYro'></q></dir></style></legend>

    <small id='xFYro'></small><noframes id='xFYro'>

      • <bdo id='xFYro'></bdo><ul id='xFYro'></ul>

      <i id='xFYro'><tr id='xFYro'><dt id='xFYro'><q id='xFYro'><span id='xFYro'><b id='xFYro'><form id='xFYro'><ins id='xFYro'></ins><ul id='xFYro'></ul><sub id='xFYro'></sub></form><legend id='xFYro'></legend><bdo id='xFYro'><pre id='xFYro'><center id='xFYro'></center></pre></bdo></b><th id='xFYro'></th></span></q></dt></tr></i><div id='xFYro'><tfoot id='xFYro'></tfoot><dl id='xFYro'><fieldset id='xFYro'></fieldset></dl></div>
      1. 使用 ShowDialog 显示对话框时如何控制对话框的位置?

        时间:2023-09-14

      2. <small id='VpzWp'></small><noframes id='VpzWp'>

        <legend id='VpzWp'><style id='VpzWp'><dir id='VpzWp'><q id='VpzWp'></q></dir></style></legend>
          • <bdo id='VpzWp'></bdo><ul id='VpzWp'></ul>

                <i id='VpzWp'><tr id='VpzWp'><dt id='VpzWp'><q id='VpzWp'><span id='VpzWp'><b id='VpzWp'><form id='VpzWp'><ins id='VpzWp'></ins><ul id='VpzWp'></ul><sub id='VpzWp'></sub></form><legend id='VpzWp'></legend><bdo id='VpzWp'><pre id='VpzWp'><center id='VpzWp'></center></pre></bdo></b><th id='VpzWp'></th></span></q></dt></tr></i><div id='VpzWp'><tfoot id='VpzWp'></tfoot><dl id='VpzWp'><fieldset id='VpzWp'></fieldset></dl></div>
              1. <tfoot id='VpzWp'></tfoot>
                  <tbody id='VpzWp'></tbody>
                • 本文介绍了使用 ShowDialog 显示对话框时如何控制对话框的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是一个非常微不足道的问题,但我似乎无法找到解决它的方法.这让我很烦,因为我觉得我应该知道这个问题的答案,但我要么在搜索错误的术语,要么在寻找错误的方法和属性.

                  This is a very trivial problem but I can't seem to find a way of solving it. It's annoying me because I feel I should know the answer to this, but I'm either searching for the wrong terms or looking at the wrong methods and properties.

                  我有一个从两个地方调用的配置对话框.

                  I have a configuration dialog that's called from two places.

                  第一个来自表单上正常工作的按钮 - 正如您所期望的那样.

                  The first is from the button on the form which is working correctly - as you'd expect.

                  第二个来自系统托盘中 notifyIcon 上的上下文菜单,但它出现在屏幕的左上方.理想情况下,我希望它显示在主屏幕的中心,或者可能靠近系统托盘.

                  The second is from a context menu on the notifyIcon in the system tray, but here it appears at the top left of the screen. Ideally I'd like it to appear centered on the primary screen, or perhaps close to the system tray.

                  • 我已经尝试设置 Location,但是当调用 dialog.ShowDialog() 时,这似乎被覆盖了.

                  • I've tried setting the Location, but this appears to be overridden when dialog.ShowDialog() is called.

                  我尝试过使用 dialog.ShowDialog(IWin32Window) 重载,但这似乎不像我将 null 作为窗口句柄传递.

                  I've tried using the dialog.ShowDialog(IWin32Window) overload, but that didn't seem to like me passing null as the window handle.

                  我已尝试改用 dialog.Show(),但是(这也是我可能会出错的地方)设置位置似乎无法提供一致的结果.

                  I've tried using dialog.Show() instead, but (and this is where I could be going wrong) setting the location doesn't appear to give consistent results.

                  我什至尝试设置 dialog.Parent 属性 - 这当然引发了异常.

                  I've even tried setting the dialog.Parent property - which of course raised an exception.

                  我只知道当我(希望)看到一些答案时,我会意识到答案是显而易见的,但此刻我完全陷入困境.

                  I just know that I'm going to realise that the answer is obvious when I (hopefully) see some answers, but at the moment I'm completely stuck.

                  感谢您的回答 - 我怀疑这很明显,但像往常一样,我让自己陷入了寻找错误路线的困境.更烦人的是我也用过设计师的这个属性.

                  推荐答案

                  您可以设置Form.StartPosition 属性为 FormStartPosition.Manual 然后设置 Form.Location 属性到您想要的位置.当您调用 ShowDialog 时,表单应显示在所需位置.

                  You can set the Form.StartPosition property to FormStartPosition.Manual and then set the Form.Location property to your desired location. When you call ShowDialog the form should show up in the desired location.

                  MyForm frm = new MyForm();
                  frm.StartPosition = FormStartPosition.Manual;
                  frm.Location = new Point(10, 10);
                  frm.ShowDialog();
                  

                  这篇关于使用 ShowDialog 显示对话框时如何控制对话框的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:获取C#保存对话框的文件路径 下一篇:如何更改 win32 窗口上的文本?

                  相关文章

                • <tfoot id='Z7uxJ'></tfoot>
                  1. <i id='Z7uxJ'><tr id='Z7uxJ'><dt id='Z7uxJ'><q id='Z7uxJ'><span id='Z7uxJ'><b id='Z7uxJ'><form id='Z7uxJ'><ins id='Z7uxJ'></ins><ul id='Z7uxJ'></ul><sub id='Z7uxJ'></sub></form><legend id='Z7uxJ'></legend><bdo id='Z7uxJ'><pre id='Z7uxJ'><center id='Z7uxJ'></center></pre></bdo></b><th id='Z7uxJ'></th></span></q></dt></tr></i><div id='Z7uxJ'><tfoot id='Z7uxJ'></tfoot><dl id='Z7uxJ'><fieldset id='Z7uxJ'></fieldset></dl></div>
                    <legend id='Z7uxJ'><style id='Z7uxJ'><dir id='Z7uxJ'><q id='Z7uxJ'></q></dir></style></legend>

                    1. <small id='Z7uxJ'></small><noframes id='Z7uxJ'>

                        <bdo id='Z7uxJ'></bdo><ul id='Z7uxJ'></ul>