About Button in Design Time Properties Window [RESOLVED!!! Thanks Pax :thumb:]
In VB6 when we made a usercontrol we could add an about button for the
design time properties window. Can we do anything similar in .NET?
Thanks.
Re: About Button in Design Time Properties Window
Oh, I didnt see your response til now. This is what I have. Aaron Young helped
me with it last night, but what I was wondering in this thread was if there
was an about button for controls that you can click on and bring up a small
form about the controls creator, etc.
I also saw that you can place hyperlinks to do action in the descriptions too.
How do you do that?
VB Code:
<Browsable(True), DefaultValue("AutoScroll"), Description("AutoScroll for XPNavBar.")> _
Public Overrides Property AutoScroll() As Boolean 'Shadows ReadOnly
Get
Return mb_AutoScroll
End Get
Set(ByVal Value As Boolean)
mb_AutoScroll = Value
End Set
End Property
1 Attachment(s)
Re: About Button in Design Time Properties Window
This is also a good alternative that I could use, but I cant find out how to do
it or what its called.
Also, how do you get the button with the elipsis (...)? I searched MSDN, but
nothing yet. :(
Re: About Button in Design Time Properties Window
Quote:
Originally Posted by RobDog888
This is also a good alternative that I could use, but I cant find out how to do
it or what its called.
Also, how do you get the button with the elipsis (...)? I searched MSDN, but
nothing yet. :(
I believe the property grid will automatically do that for you if the property is collection based.
Re: About Button in Design Time Properties Window
Thanks, but how do I create a property collection and do you know if the
hyperlink (Add Tab) is automatic also?
Re: About Button in Design Time Properties Window
Re: About Button in Design Time Properties Window
I looked through them quickly and I can see that it is part of what I need.
Do you have something for the hyperlink in the description of the property?
I will go over them in detail tomorrow. Tired. Going to sleep.
Thanks.
Re: About Button in Design Time Properties Window
Quote:
Originally Posted by RobDog888
I looked through them quickly and I can see that it is part of what I need.
Do you have something for the hyperlink in the description of the property?
I will go over them in detail tomorrow. Tired. Going to sleep.
Thanks.
No I don't. I know that'll come up if you inherit from TabPages though. If I'm not mistaken, crptcblade had a similar problem a while ago. The memories are vague though, kinda like the first age on Middle Earth...
Re: About Button in Design Time Properties Window
Hi.
You need to make a new class that inherits ControlDesigner.
Then override the Verbs property.
Return a new collection of verbs. Each verb in the collection refers to a sub in the designer. Each verb will be shown as a link in the propertywindow.
Then you need to add a DesignerAttribute to your class.
Remember to add a reference to System.Design.Dll
VB Code:
<System.ComponentModel.Designer(GetType(MyControl.MyDesigner))> _
Public Class MyControl
Inherits System.Windows.Forms.UserControl
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Label1.Dock = System.Windows.Forms.DockStyle.Fill
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(150, 150)
Me.Label1.TabIndex = 0
Me.Label1.Text = "This is a testcontrol"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'MyControl
'
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1})
Me.Name = "MyControl"
Me.ResumeLayout(False)
End Sub
#End Region
Public Class MyDesigner
Inherits System.Windows.Forms.Design.ControlDesigner
Private MyVerbs As System.ComponentModel.Design.DesignerVerbCollection
Private Sub MyAboutVerb(ByVal sender As Object, ByVal e As EventArgs)
MsgBox("You clicked the 'About' link")
End Sub
Private Sub MyAnotherVerb(ByVal sender As Object, ByVal e As EventArgs)
MsgBox("You clicked the 'AnotherVerb' link")
End Sub
Private Sub MyYetAnotherVerb(ByVal sender As Object, ByVal e As EventArgs)
MsgBox("You clicked the 'YetAnotherVerb' link")
End Sub
Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection
Get
If MyVerbs Is Nothing Then
MyVerbs = New System.ComponentModel.Design.DesignerVerbCollection()
MyVerbs.Add(New System.ComponentModel.Design.DesignerVerb("About", AddressOf MyAboutVerb))
MyVerbs.Add(New System.ComponentModel.Design.DesignerVerb("AnotherVerb", AddressOf MyAnotherVerb))
MyVerbs.Add(New System.ComponentModel.Design.DesignerVerb("YetAnotherVerb", AddressOf MyYetAnotherVerb))
End If
Return MyVerbs
End Get
End Property
End Class
End Class
Hope this helps.
EDIT: You could also take a look at www.divil.co.uk.
He has a great article about creating designers.
Re: About Button in Design Time Properties Window
Thans for the code and links guys. They are going to be very helpful. I will
try out my code tonight and if I have anymore problems I will post them.
Thanks again. :thumb:
Re: About Button in Design Time Properties Window
Pax, I am having a little trouble getting it to work. What am I doing wrong?
I did add the reference to System.Design.Dll too.
VB Code:
Imports System.ComponentModel
<ToolboxBitmap(GetType(MyControl), "MyControl.bmp")> _
Public Class MyControl
Inherits System.Windows.Forms.UserControl
[color=silver]"Windows Form Designer generated code"[/color]
Private Sub MyControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'...
'...
'...
End Sub
'CODE FOR CREATING THE HYPERLINKS TO THE DESCRIPTION WINDOW IN THE DESIGN PROPERTIES.
Public Class MyDesigner
Inherits System.Windows.Forms.Design.ControlDesigner
Private MyVerbs As System.ComponentModel.Design.DesignerVerbCollection
Private Sub MyAboutVerb(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show("About MyControl, Blah, Blah, Blah.", "MyControl", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection
Get
If MyVerbs Is Nothing Then
MyVerbs = New System.ComponentModel.Design.DesignerVerbCollection
MyVerbs.Add(New System.ComponentModel.Design.DesignerVerb("About", AddressOf MyAboutVerb))
End If
Return MyVerbs
End Get
End Property
End Class
End Class
Re: About Button in Design Time Properties Window - Not resolved
Hi.
I think you're missing the Designer attribute.
VB Code:
<[B]Designer(GetType(MyDesigner))[/B], ToolboxBitmap(GetType(MyControl), "MyControl.bmp")> _
Public Class MyControl
Inherits System.Windows.Forms.UserControl
"Windows Form Designer generated code"
Private Sub MyControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'...
'...
Re: About Button in Design Time Properties Window - Not resolved
Yes, but I didnt know how to implement it and keep my control bitmap.
Thanks, I wil give it another try. :thumb:
Re: About Button in Design Time Properties Window - Not resolved
MyDesigner is coming up as "not defined". :(
VB Code:
Imports System.ComponentModel
<Designer(GetType([color=red]MyDesigner[/color])), ToolboxBitmap(GetType(MyControl), "MyControl.bmp")> _
Public Class MyControl
Inherits System.Windows.Forms.UserControl
"Windows Form Designer generated code"
Private Sub MyControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'...
'...
'...
End Sub
'CODE FOR CREATING THE HYPERLINKS TO THE DESCRIPTION WINDOW IN THE DESIGN PROPERTIES.
Public Class MyDesigner 'BUT ITS DEFINED HERE?
Inherits System.Windows.Forms.Design.ControlDesigner
Private MyVerbs As System.ComponentModel.Design.DesignerVerbCollection
Private Sub MyAboutVerb(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show("About MyControl, Blah, Blah, Blah.", "MyControl", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection
Get
If MyVerbs Is Nothing Then
MyVerbs = New System.ComponentModel.Design.DesignerVerbCollection
MyVerbs.Add(New System.ComponentModel.Design.DesignerVerb("About", AddressOf MyAboutVerb))
End If
Return MyVerbs
End Get
End Property
End Class
End Class
Re: About Button in Design Time Properties Window - Not resolved
Sorry. My fault. :blush:
The designer is INSIDE the control class so the attribute should look like:
VB Code:
<Designer(GetType([B]MyControl.[/B]MyDesigner)), ToolboxBitmap(GetType(MyControl), "MyControl.bmp")> _
Public Class MyControl
.
.
.
Re: About Button in Design Time Properties Window - Not resolved
Yea! Error went away! I dont have time right now to do the testing on the
build but I hope it will work. Be back in a few hours.
Thanks Pax :thumb:
Re: About Button in Design Time Properties Window - Not resolved
YES, YES, YES, IT WORKS! This is so cool. I cant thank you guys enough
for your patience and help on this.
:afrog: :thumb: :D :p :)
Now its on to the "next" problem :(
Re: About Button in Design Time Properties Window [RESOLVED!!! Thanks Pax :thumb:]
Cool. Glad I could help. :thumb: