RussGreen77
Newcomer
- Joined
- Apr 30, 2005
- Messages
- 2
I'm using a property grid in my application but several of the properties I want the user to input are folder paths. How can I add a folderbrowser dialog to a grid control?
I've seen (and used) an example ofselecting a filename with the OpenFile dialog and tried to modify that. This is where I ended up but it's not working.
Any ideas?
I've seen (and used) an example ofselecting a filename with the OpenFile dialog and tried to modify that. This is where I ended up but it's not working.
Any ideas?
Code:
Public Class FolderBrowserX
Inherits FileNameEditor
Private _InitialDirectory As String
Protected Overloads Sub InitializeDialog(ByVal fbd As FolderBrowserDialog)
With fbd
.RootFolder = _InitialDirectory
End With
End Sub
Public Overloads Overrides Function GetEditStyle(ByVal context As ITypeDescriptorContext) As System.Drawing.Design.UITypeEditorEditStyle
Dim filterAtt As FileDialogParametersAttribute = _
context.PropertyDescriptor.Attributes(GetType(FileDialogParametersAttribute))
_InitialDirectory = filterAtt.InitialDirectory
Return UITypeEditorEditStyle.Modal
End Function
End Class
<AttributeUsage(AttributeTargets.Property)> _
Public Class FolderDialogParametersAttribute : Inherits Attribute
Private _InitialDirectory As String
Public ReadOnly Property InitialDirectory() As String
Get
Return _InitialDirectory
End Get
End Property
Public Sub New(Optional ByVal InitialDirectory As String = "C:\")
MyBase.New()
_InitialDirectory = InitialDirectory
End Sub
End Class