<DefaultValue(Paths.CommonAppDataPath)> Doesn't Work

J

JackRazz

Im having a problem with the <Browsable(True),
DefaultValue(Paths.CommonAppDataPath)> attribute in the Path property below. The
browser doesn't set the default value correctly when the component is dropped on a
form. When I change the property in the VS IDE property window, it remembers the
change, but when I run the app, the Path property in the component isn't set to the
same property as in the property window.


Any ideas on what I'm doing wrong??



Thanks - JackRazz


-------------------------------------------------------------------------------------
---
Public Sub New()
MyBase.new()
mPropertyList = New Hashtable()
InitializeComponent()

If Not Me.DesignMode Then
p = GetFilePath()
End If
End Sub 'New



'File Path
Public Enum Paths
AppPath
CommonAppDataPath
UserLocalAppDataPath
UserRoamingAppDataPath
End Enum
Private Const mDefaultPath As Paths = Paths.CommonAppDataPath
Private Shared mPath As Paths
<Browsable(True), DefaultValue(Paths.CommonAppDataPath)> _
Public Property Path() As Paths
Get
Return mPath
End Get
Set(ByVal Value As Paths)
mPath = Value
End Set
End Property


Private Function GetFilePath()
Dim s As String
Try
Select Case Path
Case Paths.AppPath
s = Application.ExecutablePath
Case Paths.CommonAppDataPath
s =
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
s += "\" + Application.ProductName

Case Paths.UserLocalAppDataPath
s =
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
s += "\" + Application.ProductName

Case Paths.UserRoamingAppDataPath
s =
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
s = s + "\" + Application.ProductName
End Select
Return s
Catch
End Try

End Function
 
J

JackRazz

Ok, I've sorted out the problem with the property not being set at run time. I was
trying to initilize the path field before the code in the form initilizer initilize
the components properties. Only one issue left, setting the default property.

JackRazz


| Im having a problem with the <Browsable(True),
| DefaultValue(Paths.CommonAppDataPath)> attribute in the Path property below. The
| browser doesn't set the default value correctly when the component is dropped on a
| form. When I change the property in the VS IDE property window, it remembers the
| change, but when I run the app, the Path property in the component isn't set to the
| same property as in the property window.
|
|
| Any ideas on what I'm doing wrong??
|
|
|
| Thanks - JackRazz
|
|
| -----------------------------------------------------------------------------------
--
| ---
| Public Sub New()
| MyBase.new()
| mPropertyList = New Hashtable()
| InitializeComponent()
|
| If Not Me.DesignMode Then
| p = GetFilePath()
| End If
| End Sub 'New
|
|
|
| 'File Path
| Public Enum Paths
| AppPath
| CommonAppDataPath
| UserLocalAppDataPath
| UserRoamingAppDataPath
| End Enum
| Private Const mDefaultPath As Paths = Paths.CommonAppDataPath
| Private Shared mPath As Paths
| <Browsable(True), DefaultValue(Paths.CommonAppDataPath)> _
| Public Property Path() As Paths
| Get
| Return mPath
| End Get
| Set(ByVal Value As Paths)
| mPath = Value
| End Set
| End Property
|
|
| Private Function GetFilePath()
| Dim s As String
| Try
| Select Case Path
| Case Paths.AppPath
| s = Application.ExecutablePath
| Case Paths.CommonAppDataPath
| s =
| Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
| s += "\" + Application.ProductName
|
| Case Paths.UserLocalAppDataPath
| s =
| Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
| s += "\" + Application.ProductName
|
| Case Paths.UserRoamingAppDataPath
| s =
| Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
| s = s + "\" + Application.ProductName
| End Select
| Return s
| Catch
| End Try
|
| End Function
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top