控制边界 [英] Borders around control

查看:106
本文介绍了控制边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义控件.当我在控件周围添加边框时,边框超出了控件右侧和底部的界限.我以为我曾经知道一种防止边界这样做的方法,但我已经不记得了.有什么想法吗?

I have a custom control that I am making. When I add a border around the control the border goes outside the bounds of the control on the right and bottom side. I thought I once knew a way to prevent the border from doing this, but I no longer remember. Any ideas?

推荐答案

事实证明,控件绘制的笔画实际上会增加控件的大小.因此,无论笔画粗细如何,为了使控件的大小保持恒定,我执行了以下操作:

我将控件的渲染部分向下和向右平移了笔触厚度的一半.
我通过笔触厚度同时减小了高度和宽度.

到目前为止,这似乎已经解决了我的问题!
It turns out that the stroke that is drawn by a control actually adds on to the size of the control. So in order to keep my control appear at a constant size no matter what the stroke thickness is, I did the following:

I translated the rendered portion of my control down and to the right by half the stroke thickness.
I decreased both the height and width by the stroke thickness.

So far this seems to have solved my problem!


这篇关于控制边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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