|
-
Apr 13th, 2007, 11:48 PM
#1
[2005] Show File Properties
Dear all,
How to show the File Properties in Property Gird
dana
Please mark you thread resolved using the Thread Tools as shown
-
Apr 14th, 2007, 01:26 AM
#2
Re: [2005] Show File Properties
Probably best for reuse, create a class with the properties you are wanting to display in the PG. Then populate from the selected file. Then bind the class to the PG using the .SelectedObject property. Using attribute tags on your props designate how and where they are shown in the grid, if at all desired.
VB Code:
Imports System.ComponentModel
Public Class PropertyClass
Private mprop1 As String = "Text"
Private mprop2 As Integer = 1
Private mprop3 As Bitmap
Private mprop4 As Color = Color.Red
<Category("Category1"), DefaultValue("Text")> _
Public Property Property1() As String
Get
Return mprop1
End Get
Set(ByVal Value As String)
mprop1 = Value
End Set
End Property
<Category("Category1"), DefaultValue(1)> _
Public Property Property2() As Integer
Get
Return mprop2
End Get
Set(ByVal Value As Integer)
mprop2 = Value
End Set
End Property
<Category("Category2")> _
Public Property Property3() As Bitmap
Get
Return mprop3
End Get
Set(ByVal Value As Bitmap)
mprop3 = Value
End Set
End Property
<Category("Category2"), DefaultValue(GetType(Color), "Red")> _
Public Property Property4() As Color
Get
Return mprop4
End Get
Set(ByVal Value As Color)
mprop4 = Value
End Set
End Property
End Class
Example Usage:
VB Code:
Private mproperties As New PropertyClass
Private propGrid As New PropertyGrid
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
propGrid.Location = New Point(10, 10)
propGrid.Size = New Size(200, 250)
propGrid.Dock = DockStyle.Fill
propGrid.CommandsVisibleIfAvailable = True
propGrid.Text = "My Property Grid"
pnlPropGrid.Controls.Add(propGrid)
propGrid.SelectedObject = mproperties
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Save mproperties content here
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 16th, 2007, 03:44 AM
#3
Re: [2005] Show File Properties
Dear Robert,
Thanks for your reply.Now I found this code do display the default file properties.
vb Code:
PropertyGrid1.SelectedObject = New FileInfo("c:\test.txt")
And now I can add some properties to this additionally
Please mark you thread resolved using the Thread Tools as shown
-
Apr 16th, 2007, 01:45 PM
#4
Re: [2005] Show File Properties
Cool, didnt think about doing it that way but if you want to override some of the default properties then you will need the intermediate class like I posted.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 16th, 2007, 11:28 PM
#5
Re: [2005] Show File Properties
Can we able to add some extra property to inaddition to the default showing when this command is executed
vb Code:
PropertyGrid1.SelectedObject = New IO.FileInfo("filename.ext")
Please mark you thread resolved using the Thread Tools as shown
-
Apr 16th, 2007, 11:34 PM
#6
Re: [2005] Show File Properties
You can only show properties of the object that you've assigned to the SelectedObject property of the grid. If you want to show other properties then you'd have to assign a different type of object that has those properties. You can define your own type that wraps a FileInfo and provides those additional properties if you like.
-
Apr 17th, 2007, 12:28 AM
#7
Re: [2005] Show File Properties
Dear JMC,
Wheather I have to write a new wrapper for all the properties of the Fileinfo.Or just inherit the existing property and add my properties /
Please mark you thread resolved using the Thread Tools as shown
-
Apr 17th, 2007, 12:49 AM
#8
Re: [2005] Show File Properties
Which do you think would be better and why? Is there any impediment to doing it that way?
-
Apr 17th, 2007, 01:15 AM
#9
Re: [2005] Show File Properties
I think inheriting the existing properties,adding new properties (mine) and showing is will be the best one
Please mark you thread resolved using the Thread Tools as shown
-
Apr 17th, 2007, 01:18 AM
#10
Re: [2005] Show File Properties
What benefit(s) does that provide? Is there any impediment to doing it that way? Is there any benefit to doing it the other way?
-
Apr 17th, 2007, 02:55 PM
#11
Re: [2005] Show File Properties
I think the question is what are you trying to accomplish? Just showing the default properties, showing and adding new properties, showing and overriding default properties, etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 17th, 2007, 10:43 PM
#12
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|