万能控制-关于码头和锚点的简单问题

发布于 2024-08-27 01:14:59 字数 306 浏览 5 评论 0原文

我使用 Visual Studio .NET 来开发内部应用程序。我创建一个将显示自定义状态栏信息的 Windows 控件。不同的开发人员会使用该控件在许多不同的应用程序中显示相同的信息。在每个应用程序中,该控件必须始终显示在父窗体的底部。它必须始终与表格一样宽。当调整窗体大小时,应相应地调整控件的大小和位置。 我应该如何以最好的方式做到这一点,为什么? A)创建一个属性,允许开发者设置控件的Dock属性。将属性的默认值设置为 AnchorStyle.Bottom。 B) 创建一个属性以允许开发人员设置控件的 Anchor 属性。将属性的默认值设置为 AnchorStyle.Bottom。

I use Visual Studio .NET to develop internal applications. I create a Windows control that will display custom status bar information. Different developers will use the control to display the same information in many different applications. The control must always be displayed at the bottom of the parent form in every application. It must always be as wide as the form. When the form is resized, the control should be resized and repositioned accordingly.
How should I do that in the best way and why? A)Create a property to allow the developers to set the Dock property of the control. Set the default value of the property to AnchorStyle.Bottom. B) Create a property to allow the developer to set the Anchor property of the control. Set the default value of the property to AnchorStyle.Bottom.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秋意浓 2024-09-03 01:14:59

如果您希望控件始终位于其容器的底部,那么您应该使用 Dock 属性。停靠控件会将控件附加到其容器的边缘或完全填充容器。

使用 Anchor 定义其容器的一个或多个边缘之间的恒定距离。

谢谢巴里

If you want your control to always be at the bottom of it's container then you should use the Dock property. Docking a control attaches the control to an edge of it's container or fill the container completely.

Using Anchor defines a constant distance between one or more edges of it's container.

Thanks

Barry

淡淡的优雅 2024-09-03 01:14:59

Dock 就是您所追求的 - 查看 Statusbar 控件即可了解。

像这样的东西应该覆盖它:

  [DefaultValue(2)]
  public override DockStyles Dock {
    get { return base.Dock; }
    set { base.Dock = value; }
  }

编辑: 似乎 2 是底部

Dock is what you are after for this - take a look at the Statusbar control to see.

Something like this should cover it:

  [DefaultValue(2)]
  public override DockStyles Dock {
    get { return base.Dock; }
    set { base.Dock = value; }
  }

Edit: Seems that 2 is Bottom

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文