在C#中找不到PictureBox的Pixel属性的情况? [英] Don't find situation of Pixel property of PictureBox in C#?

查看:63
本文介绍了在C#中找不到PictureBox的Pixel属性的情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在窗体中有一个PictureBox,我想将PictureBox的单位设置为Pixel,但是在PictureBox的属性"窗口中看不到任何属性,请帮我做一下,因为在PiictureBox上绘制了图形.谢谢.

I have a PictureBox inside a Form, I want to set unit of PictureBox is Pixel, but I dont see any property in Properties window of PictureBox, please help me do this, because of drawing graphic on PiictureBox. Thanks.

推荐答案

您不应使用PictireBox控件绘制任何图形.为此,最好使用从System.Windows.Forms.Control派生的自定义控件.碰巧,图片框"这个名称误导了许多尝试滥用此控件的初学者.可以使用此控件,甚至实现一些交互式或动画功能……这根本没有意义,因为此控件根本无法帮助绘制;相反,它增加了一些麻烦,并且占用了额外的资源和开发时间,降低了性能.它的设计目的很简单:为不希望了解图形渲染的人们显示静态图像.

当您确实需要绘制某些东西时,您只是试图完全使用错误的控件,而并​​非为此目的而设计.

我将向您解释如何使用GDI进行绘制.请查看我过去的答案:
如何从旧图纸中清除面板 [ ^ ],
在C#中绘制矩形 [在图片框内添加图片 [在mdi子表单之间画线 [在面板上捕获图形 [ Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [
You should not draw any graphics using PictireBox control. For this purpose, it''s much better to use a custom control, derived from System.Windows.Forms.Control. It so happened that the name "picture box" mislead many beginners who try to abuse this control. It is possible to draw on this control and even implement some interactive or animated functionality… it makes no sense at all, because this control does not help drawing at all; just the opposite, it adds some hassled and eats additional resources and development time, reduce performance. It was designed for a simple purpose: display a static image, for people who would not want to know anything about graphics rendering.

As you really need to draw something, you just trying to use totally wrong control not designed the this purpose.

I''ll explain you how to draw using GDI. Please see my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^].

See also these answers on rendering and related detail:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^].

—SA


这篇关于在C#中找不到PictureBox的Pixel属性的情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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