Custom properties are set to control the width or height of the control, but the data is not normal

Source: Internet
Author: User

Although set a certain value, but always automatically changed to another value, such as the width is set to 100, but run or reopen the form design interface, the width automatically becomes 133, such as more open several times, or even become larger, looking for a long time, also can not find the reason, after many attempts to find the reason before for the easy, When setting a custom property, use the following format:
  
 
  1. <Category("MAX Member")> _
  2. Public Property mShowControlLength As Integer
  3. Get
  4. Return xShow.Width
  5. End Get
  6. Set(value As Integer)
  7. xShow.Width = value
  8. End Set
  9. End Property
Theoretically, there is no problem, but it will cause this value can not be fixed, even bigger, and later changed to the following format, finally fixed:
  
 
  1. <Category("MAX Member")> _
  2. Public Property mShowWidth As Integer
  3. Get
  4. Return _showWidth' Use a custom variable to output a set value
  5. End Get
  6. Set(value As Integer)
  7. _showWidth = value
  8. xShow.Width = _showWidth
  9. If (Me.DesignMode) Then
  10. xItemPanel.Refresh()
  11. End If
  12. End Set
  13. End Property
cause analysis, because the controls in the control themselves do not store the set values, then when the width is obtained, it isprogrambased on the current situation, the width of the calculation is unpredictable, so it is displayed as a random, large value, and then saved as a set value based on this value. That's what happened, take this lesson and don't do it again .

Custom properties are set to control the width or height of the control, but the data is not normal

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.