Hello, there is some misunderstanding with such a thing as an event. Just basically wrote only console applications. In general, the task is simple: by pressing the button in the panel , some drawing should appear. I need to somehow trigger some other drawing event in the button_click method. I tried to just directly write directly: button1.Click = new System.Windows.Forms.PaintEventHandler(this.panel1_Paint) , but the compiler swears at the PaintEventHandler delegate, requires EventHandler . Thank you in advance. And in general, I would be extremely grateful if someone told the site where there are a bunch of examples of working with various components and how to link them.
|
3 answers
The Paint event is fired when the control is redrawn.
Create an event handler
private void SomePaintEventHandler(object sender, PaintEventArgs args) { // В качестве примера args.Graphics.DrawString("Text", new Font ("Tahoma", 12), new SolidBrush (Color.Green), 200, 200); } We delegate the event
this.Paint += new PaintEventHandler(this.SomePaintEventHandler); We initiate copying
this.Invalidate(); Read on: handling and call events .
|
MSDN: PaintEventHandler - delegate .
- I have one MSDN not working? - Specter
|
Windows applications - WinForms is a very good site for beginners, I hope you will find a lot of useful information for yourself.
|