PropertyGrid - how to show spaces in property name and how to have file browser for a field

  • Thread starter Thread starter wingers
  • Start date Start date
W

wingers

Guest
Hi

I am using a PropertyGrid control in my app to show a list of different settings and for most areas it works fine, apart from the following

1) How can I have spaces in the names showing in the grid e.g. instead of it showing "CopyFilesAndDirectories" I want it to show "Copy Files And Directories"

2) How can for a particular field I add a file/folder browse dialog icon so I can click it to open dialog, select folder or file and it then populates value

My code is a mismatch of bits found on internet so far, will put basic idea below

This is my form code, and form itself has a property grid control added

Public Class Form1

Dim _MySettings As MySettings = New MySettings ()

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

PropertyGrid1.SelectedObject = _MySettings
PropertyGrid1.PropertySort = PropertySort.Categorized
PropertyGrid1.ToolbarVisible = False

End Sub

End Class

Then I have a class containing my settings to show in the grid

Imports System.ComponentModel

Public Class MySettings

' Copy Options
Private _CopyFilesAndDirectories As Boolean = False

' Logging Options
Private _LogPath As String = ""


<DescriptionAttribute("Copy Files And Directories (/S) - Copies subdirectories. Note that this option excludes empty directories"), ReadOnlyAttribute(False), CategoryAttribute("Copy Options")>
Public Property CopyFilesAndDirectories() As Boolean
Get
Return _CopyFilesAndDirectories
End Get
Set(ByVal Value As Boolean)
_CopyFilesAndDirectories = Value
End Set
End Property



<DescriptionAttribute("Log File (/LOG:file) - Output status to LOG file (overwrite existing log)"), ReadOnlyAttribute(False), CategoryAttribute("Logging Options")>
Public Property LogPath() As String
Get
Return _LogPath
End Get
Set(ByVal Value As String)
_LogPath = Value
End Set
End Property

End Class


So it then looks like the below

1355273.jpg

And I would like spaces to be shown so it makes options easier to read

And for the log file one ability to have browse icon at end of field to easily select a file/folder

Any thoughts please?







Darren Rose

Continue reading...
 
Back
Top