在按钮上单击绘制形状

在按钮上单击绘制形状

本文介绍了在按钮上单击绘制形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个Windows Forms应用程序,并且想要在Button单击上绘制形状.如何在Button_Click事件中调用Form_Paint?

I create a Windows Forms application and I want to draw a shape on the Button click.How can I call Form_Paint on the Button_Click event?

推荐答案

要用手抬起油漆,请阅读此SO帖子(基本上调用Invalidate()方法)

To raise the Paint even by hand read this SO post (basically call the Invalidate() method)

SO帖子:我怎么称呼绘画事件?

但是,您可能需要具有某种内部"drawshape"标志,您可以在单击按钮时设置/清除该标志,并检查内部的paint even handler方法.此标志将告诉您的paint事件处理程序,以继续绘制您的形状或根本不绘制您的形状(每次调用表单paint时)

However, you'll probably need to have some sort of internal "drawshape" flag that you set/clear on the button click and check inside your paint even handler method. This flag will tel your paint event handler to either continue drawing your shape or not draw your shape at all (every time the form paint is called)

这篇关于在按钮上单击绘制形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 13:30