Head first C # Chinese Version chapter 13th controls and graphics page577

Source: Internet
Author: User

 

Beecontrol also needs to release its own controls



The control class implements
Idisposable
Interface, so you need to make sure that each used control is released.
Beecontrol
Contains
Timer
Control, but it cannot be released. This is a problem. Fortunately, this problem is easily fixed.
--
Overwrite
Dispose
() Method.



③ Override dispose
() Method to release
Timer



Beecontrol inherited from
Control
, So it must contain
Dispose
() Method. So we can override this method to release it.
Timer
. Enter the code and type
Override
:



 

Click dispose in the smart sensing window.
,
IDE
Will be used
Base. Dispose
() Fill this method with this statement:



 

④ Add code to process Timer



To ide
Add a row for the filling method:



 

Now your beecontrol
Can be processed
Timer
. Set
IDE
Leave the line of code generated for you there.
Picturebox
It can also be processed.



Clear timer now
Already
Beecontrol
Of
Dispose
() Part of the method.



Custom controls must be used to clear other controls created in them.

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.