我们如何将paint事件添加到用户控件?
问题描述:
我有用户控件。如何添加绘图事件?
I have user control.How can I add paint event to it?
答
在VS的设计视图中打开你的控件。
突出显示整个控件 - 而不是它包含的组件 - 如果您不确定,可以在属性窗格中通过从窗格顶部的ComboBox中选择UserControl类名来执行此操作。
单击看起来像闪电的小按钮选择事件。
向下滚动到Paint事件,然后双击。这将添加默认处理程序代码,并为您准备好添加绘图代码的方法。
Open your control in design view in VS.
Highlight the whole control - rather than a component it contains - you can do this in the Properties pane by selecting the UserControl class name from the ComboBox at the top of the pane if you aren't sure.
Select "Events" by clicking the little button that looks like a lightning bolt.
Scroll down to the "Paint" event, and double click. This will add default handler code and put you in the method ready to add your painting code.