c#中的图像定位 [英] Image positioning in c#
本文介绍了c#中的图像定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将图像放在c#中的指定位置?当我们点击图像时,图像必须出现在指定的位置..!
解决方案
请参阅:http://msdn.microsoft.com/en-us/library/42807xh1(v=vs.110).aspx [ ^ ]。
您可以将此代码放在事件的处理程序中System.Windows.Forms.Control.Paint
或重写的虚方法System.Windows.Forms.Control.OnPaint
。绘图所需的类System.Drawing.Graphics
的实例将在事件参数中传递给您的处理程序。请参阅:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.paint%28v=vs.110%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onpaint(v = vs.110).aspx [ ^ ],
http:// msdn.microsoft.com/en-us/library/system.drawing.graphics%28v=vs.110%29.aspx [ ^ ]。
要移动位置,请更改数据中的位置您用于渲染并调用System.Windows.Forms.Control.Invalidate
:
http://msdn.microsoft.com/en-us/library/system.windows.forms .control.invalidate%28v = vs.110%29.aspx [ ^ ]。
-SA
How to place a image in a specified position in c#? When we click on the image the image will have to appear in a specified position..!
解决方案
Please see: http://msdn.microsoft.com/en-us/library/42807xh1(v=vs.110).aspx[^].
You can place this code in a handler of the eventSystem.Windows.Forms.Control.Paint
or overridden virtual methodSystem.Windows.Forms.Control.OnPaint
. The instance of the classSystem.Drawing.Graphics
needed for drawing will be passed to your handler in event arguments. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.paint%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.onpaint(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.graphics%28v=vs.110%29.aspx[^].
To move the location, change location in the data you use for rendering and callSystem.Windows.Forms.Control.Invalidate
:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.invalidate%28v=vs.110%29.aspx[^].
—SA
这篇关于c#中的图像定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文