[.net] "Refreshing" Event Code

Started by
3 comments, last by vermilion_wizard 16 years, 10 months ago
How could I go about making the onclick event from a button refresh/reload a user control? or even another event?
Advertisement
What exactly do you mean by refresh/reload? There's the Refresh method on the control, which just repaints it. If it's your own UserControl, you could just add a public Reload() method on the control, and call that from your event handler, then do whatever you need to inside the Reload method.
Quote:Original post by Selacius
How could I go about making the onclick event from a button refresh/reload a user control? or even another event?

Control.Invalidate() ?
Okey, this is wat I have. A user control for my explore procedure. Using code from previous, I draw the map as a graphics and display it in a picturebox. Now on this user control I also have 4 buttons (north, south, east, west). The player is located at the center of the map, and when one of the buttons is pushed, the location moves. Now, I could have the buttonclick events for each button redraw the tile that the player had occupied and move the player to the new tile. But because of the way I have things setup, the player is always in the middle of the map, and its just the boundaries change. It's always a 7x7 or so viewing area. So I need a way that I can click the button, and the onclick event refreshes the user control to redraw the map.
Yeah, it sounds like you want to call Refresh or Invalidate on the user control then. If the buttons are declared inside the user control then call this.Invalidate inside the click handlers.

This topic is closed to new replies.

Advertisement