Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27186

VS 2010 Defaultvalue for usercontrol custom color property (@design- & runtime)

$
0
0
Hi,

I created a usercontrol that has a custom property "XColor" (color type), which I want to set to "Color.Yellow" (RGB 255,255,0) as default, both at designtime and runtime.

I googled around, to find out that I would have to need "System.ComponentModel.DefaultValue", however, this has some overloads that provide access to all standard datatypes (integer, byte, etc...), and even to an object type, but you can not access a color-type directly.

Am I forced to create some object, that holds the color, or is there a simpler way?

I used the following code to, bet that doesn't seem to have any effect for design-time placed usercontrol instances:

Code:

Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

              XColor = Color.Yellow
    End Sub

I haven't checked out is this works for runtime created instances too (but I suppose it will).

How do I set XColor to Color.Yellow?

Viewing all articles
Browse latest Browse all 27186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>