图形和绘图 [英] Graphics and Drawing
本文介绍了图形和绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好!
在我的程序中,我正在添加一个控件,并且是一个tablelayout,我放置了一个事件以通过鼠标来移动它..所有这些都很容易,但是现在是一个问题((我正在通过绘制线绘制一条线方法,我想将这条线连接到两个表之间,并且当我尝试移动与此表连接的任何表时都希望这条线移动)).
致以最诚挚的问候.
Hello!
in my program i''m adding a controls and that''s a tablelayout and I put an event to move it via mouse .. and all of that are easy but the question now (( I''m drawing a line via draw line method and I want to connect this line between two table and I want this line move when I try to move any table who''s connect with this line )).
With my best regards.
推荐答案
您可能想要处理绘画事件并在其中绘制所有对象.实现此目的的经典方法是拥有代表不同对象及其位置的类实例的集合.当鼠标事件意味着您需要重新绘制窗体时,请调用Invalidate()强制进行绘制事件.您的代码只需更改这些对象的值,您的绘制代码即可简单地遍历对象并绘制它们.
You will probably want to handle your paint event and draw all your objects in there. The classic way to do this, is to have a collection of class instances that represent different objects and their location. When your mouse events mean you need to redraw the form, call Invalidate() to force a paint event. Your code just changes the values of these objects, your paint code simply iterates over the objects and draws them.
这篇关于图形和绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文