Current location: Hot Scripts Forums » Programming Languages » Windows .NET Programming » [SOLVED] [2005] CustomButtonControl - Defaults declared in New overriding values


[SOLVED] [2005] CustomButtonControl - Defaults declared in New overriding values

Reply
  #1 (permalink)  
Old 02-25-08, 11:30 AM
tim8w tim8w is offline
Wannabe Coder
 
Join Date: Nov 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy [SOLVED] [2005] CustomButtonControl - Defaults declared in New overriding values

I have a CustomButton control where I set up some Property defaults in the New of the control. Problem is that they totally override what the user has entered in the Property for the control. In fact it changes them to the values that are in the New routine when the project is run. I've done this same thing before many times without any problems. Any suggestions?

Here's the New code:

Code:
<ToolboxBitmap(GetType(BubbleButton), "BubbleButton.bmp")> _
Public Class BubbleButton : Inherits Control

    Private components As System.ComponentModel.IContainer
    Private ttBubbleButton As System.Windows.Forms.ToolTip = New ToolTip

    Private m_Blur As Boolean = False
    Private m_ButtonImage As Bitmap
    Private m_ButtonImage60 As Bitmap
    Private m_ButtonImage120 As Bitmap
    Private m_ButtonImage180 As Bitmap
    Private m_InitialSize As Size
    Private m_DialogResult As Windows.Forms.DialogResult

    Dim iFlag As Integer
    Dim bEnter As Boolean = False
    Dim dCurrentWidth, dCurrentHeight As Double
    Dim dAddX, dAddY As Double
    Dim bBlur As Boolean = True
    Dim g1, g2 As Graphics
    Dim bmpDoubleBuffer As Bitmap

    Friend WithEvents tmrBubbleButton As System.Windows.Forms.Timer

    Sub New()
        components = New System.ComponentModel.Container
        tmrBubbleButton = New System.Windows.Forms.Timer(components)
        tmrBubbleButton.Interval = 10
        ' ---------------------------------------------------------------------
        ' New Button
        ' ---------------------------------------------------------------------
        '
        '
        ' Setup defaults
        Size = New Size(48, 48)
        InitialSize = New Size(Size.Width / 2, Size.Height / 2)
        Blur = True

        m_ButtonImage = New Bitmap(Width, Height)
        m_ButtonImage60 = New Bitmap(Width, Height)
        m_ButtonImage120 = New Bitmap(Width, Height)
        m_ButtonImage180 = New Bitmap(Width, Height)
        bmpDoubleBuffer = New Bitmap(Width, Height)
        g1 = Me.CreateGraphics
    End Sub
Here's the code for the Property in question:

Code:
    <Category("Appearance"), _
    Description("Expand to specifiy the Initial Size of the Icon when not in focus."), DefaultValueAttribute(32), _
    DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
    Public Property InitialSize() As Size
        Get
            InitialSize = m_InitialSize
        End Get
        Set(ByVal Value As Size)
            If Value.Width > Width Then
                Value.Width = Width
            End If
            If Value.Height > Height Then
                Value.Height = Height
            End If
            m_InitialSize = Value
            Calc()
        End Set
    End Property
Reply With Quote
  #2 (permalink)  
Old 02-25-08, 01:12 PM
tim8w tim8w is offline
Wannabe Coder
 
Join Date: Nov 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Resolved: [2005] CustomButtonControl - Defaults declared in New overriding values

A user in another forum found the answer. No explanantion as to why it has to be done but basically the value for 'DesignerSerializationVisibility' needs to be set to 'Visible' and not 'Content'

Code:
   <Category("Appearance"), _
    Description("Expand to specifiy the Initial Size of the Icon when not in focus."), DefaultValueAttribute(32), _
    DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    Public Property InitialSize() As Size
        Get
            InitialSize = m_InitialSize
        End Get
        Set(ByVal Value As Size)
            If Value.Width > Width Then
                Value.Width = Width
            End If
            If Value.Height > Height Then
                Value.Height = Height
            End If
            m_InitialSize = Value
            Calc()
        End Set
    End Property
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Auto Dealer Script nuzzle PHP 17 04-14-10 08:34 PM
How to store multiple values in a string without overriding the pervious one bamboat_3 ASP.NET 3 08-26-04 09:08 AM
MySQL table problem perleo PHP 9 12-16-03 01:16 PM
asp: values in array not in order?? seala ASP 0 08-16-03 12:06 PM


All times are GMT -5. The time now is 02:16 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.