Solved

preserve custom property value

Posted on 2004-10-25
177 Views
Last Modified: 2010-04-23
I am extending PictureBox control and added the following code

    Private clrForeColor As Color = Color.Black

    <Browsable(True)> _
    Overrides Property ForeColor() As Color
        Get
            Return clrForeColor
        End Get
        Set(ByVal Value As Color)
            clrForeColor = Value
            MyBrush.Color = clrForeColor
            Me.Invalidate()
        End Set
    End Property

Whe I change my ForeColor property from the property window the color changes but when executing the application the color rturns to black. How o solve this problem?
0
Question by:f_asmaa
    5 Comments
     
    LVL 19

    Expert Comment

    by:arif_eqbal
    That's because your code executes only at run time

    I think you need to create a custom control for that, extend the picture box using a new Windows Control Library Project and adding your code then use this new control.

    0
     

    Author Comment

    by:f_asmaa
    What do you mean by executing the code at run time??????
    0
     
    LVL 19

    Expert Comment

    by:arif_eqbal
    How have you extended the Picture Box Control
    It must be a class within your project

    However when you access the property pages it is the basic PictureBox control isn't it
    And not your extended class



    0
     

    Author Comment

    by:f_asmaa
    No I see the additional property that I added. I added a control library project to my application and added referenc to from my application.
    0
     
    LVL 25

    Accepted Solution

    by:
    Hi, call the base class forecolor

    <Browsable(True)> Public Overrides Property ForeColor() As Color
            Get
                Return clrForeColor
            End Get
            Set(ByVal Value As Color)
                clrForeColor = Value
                MyBrush.Color = clrForeColor
                Me.Invalidate()
    '*****
                MyBase.ForeColor = Value
    '*****
            End Set
        End Property
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: MongoDB Object-Document Mapper for NodeJS

    NodeJS (JavaScript on the server) is awesome, but some developers get confused about NoSQL when it comes to working in Node with MongoDB (NoSQL database). Do you need a better explanation of how to use Node.js with MongoDB? The most popular choice is the Mongoose library.

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    857 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now