UserControl ClientRectangle 比它说的要小 [英] UserControl ClientRectangle is smaller than it says

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

问题描述

我正在尝试使用自定义边框制作我的 UserControl(我在属性中将默认边框样式更改为无" - 我创建了控件并调用了 Graphics.DrawRectangle(...,ClientRectangle).我所看到的只是我绘制的矩形的顶部和左侧边框 - 似乎我可以绘制的区域的实际大小与 ClientRectangle 不同......如何更改它/获得正确的 ClientRectangle 大小?

I am trying to make my UserControl with custom borders (I changed default border style to "none" in properties - I created control and I am invoking Graphics.DrawRectangle(...,ClientRectangle). And what I see is only the top and left borders of my painted rectangle - it seems that real size of the area where I can draw is different than ClientRectangle... How to change it / get the right ClientRectangle size?

推荐答案

ClientRectangle 返回独坐标中的矩形,因此您需要从底部和右侧减去 1.无论当前图形模式中每像素有多少个单位,这都将起作用,如果我错了,有人纠正我.

ClientRectangle returns the rectangle in exclusive coordinates so you need to subtract 1 from the bottom and right hand sides. This will work regardless of how many units per pixel there are in the current graphics mode, someone correct me if I am wrong.

这篇关于UserControl ClientRectangle 比它说的要小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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