如何在WinForms中使子控件的位置相对? [英] How to make location of children controls in WinForms relative?

查看:64
本文介绍了如何在WinForms中使子控件的位置相对?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从Control派生的自定义控件,该控件被动态添加到表单中。控件在位置中可以具有负值,并且默认情况下是相对于左上角绘制的。

I have a custom control derived from Control which is dynamically added to the form. The control can have negative values in Location and is by default painted relative to the top left corner.

我如何才能使控件具有负坐标并相对于右侧绘制

How can I get the control to have negative coordinates and painted relative to right bottom corner for example?

推荐答案

问题标题和问题问了两个不同的问题。

The question title and the question ask two different things.

标题:是的,您可以进行相对放置,但是您需要使用嵌套的布局面板,例如TableLayoutPanel和FlowLayoutPanel。他们应该能够完成大部分(如果不是全部)您想做的事情。

For the title: yes, you can do relative placement, but you'll need to use nested layout panels, like TableLayoutPanel and FlowLayoutPanel. They should be able to do most, if not all, of what you want to do.

对于实际问题:


  1. 为什么?

  2. 不,你不能。

这篇关于如何在WinForms中使子控件的位置相对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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