473,394 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

adding properties at design time

Hi,

I'm looking resources or tutorial where I can learn how to add
properties to other objects at design time for VB.NEt or C#.

I want to reproduce the same effect as when your drop the tooltip object
on a form. Once it's done, every object has a new property added to the
property box so we can write the tooltip text.

Syncfusion object does something like that when we drop a docking
manager tool. It adds 3 new properties to every object that can use this
resources.

I tried to find information but maybe because I don't know how to call
that effect, I was not succesfull to find information.

Thank you very much.

Miky
*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
2 1708
The thing you need is an object that implements IExtenderProvider.

An extender-provider can "extend" other object by appearing to add
properties to them at design time. Note that at runtime the process is
handled differently.

The object being extended has no knowlege of the new properties either.

After my signature you'll find a simple extender-provider that adds "status"
properties to menu items. These properties can be displayed in a status bar
chosen at design time.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
Imports System

Imports System.ComponentModel

Imports System.Collections

Imports System.Drawing

Imports System.Windows.Forms

<ToolboxItem(True), _

ToolboxBitmap(GetType(MenuStatusExtender), "MenuStatusExtender.bmp"), _

ProvideProperty("StatusText", "System.Windows.Forms.MenuItem") _
_
Public Class MenuStatusExtender

Inherits Component

Implements IExtenderProvider

Private _extendees As New Hashtable

Public Sub New()

End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

Dim mi As MenuItem

If Not Me.DesignMode Then

For Each mi In _extendees.Keys

RemoveHandler mi.Select, AddressOf Me.MenuStatusExtender_Select

Next

End If

_extendees.Clear()

MyBase.Dispose(disposing)

End Sub

Public Overridable Function CanExtend(ByVal extendee As [Object]) As Boolean
Implements IExtenderProvider.CanExtend

Return TypeOf extendee Is MenuItem

End Function

Public Function GetStatusText(ByVal item As MenuItem) As String

If _extendees.ContainsKey(item) Then

Return CType(_extendees(item), String)

Else

Return ""

End If

End Function

Public Sub SetStatusText(ByVal item As MenuItem, ByVal s As String)

If _extendees.ContainsKey(item) Then

_extendees(item) = s

Else

If Not Me.DesignMode Then

AddHandler item.Select, AddressOf Me.MenuStatusExtender_Select

End If

_extendees.Add(item, s)

End If

End Sub

Private Sub MenuStatusExtender_Select(ByVal sender As Object, ByVal e As
EventArgs)

OnItemSelected(New ItemSelectEventArgs(_extendees(sender)))

End Sub

Private Sub OnItemSelected(ByVal e As ItemSelectEventArgs)

RaiseEvent ItemSelected(Me, e)

End Sub

Public Event ItemSelected As ItemSelectEventHandler

End Class

Public Class ItemSelectEventArgs

Inherits EventArgs

Private _statusMessage As String

Protected Sub New()

End Sub

Public Sub New(ByVal message As String)

_statusMessage = message

End Sub

Public ReadOnly Property StatusMessage() As String

Get

Return _statusMessage

End Get

End Property

End Class

Public Delegate Sub ItemSelectEventHandler(ByVal sender As Object, ByVal e
As ItemSelectEventArgs)

"Miky" <no****@virtuelcom.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... Hi,

I'm looking resources or tutorial where I can learn how to add
properties to other objects at design time for VB.NEt or C#.

I want to reproduce the same effect as when your drop the tooltip object
on a form. Once it's done, every object has a new property added to the
property box so we can write the tooltip text.

Syncfusion object does something like that when we drop a docking
manager tool. It adds 3 new properties to every object that can use this
resources.

I tried to find information but maybe because I don't know how to call
that effect, I was not succesfull to find information.

Thank you very much.

Miky
*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #2
Miky,

Take a look at the Extender Provider:
http://msdn.microsoft.com/library/de...erprovider.asp

HTH,
-B
"Miky" <no****@virtuelcom.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,

I'm looking resources or tutorial where I can learn how to add
properties to other objects at design time for VB.NEt or C#.

I want to reproduce the same effect as when your drop the tooltip object
on a form. Once it's done, every object has a new property added to the
property box so we can write the tooltip text.

Syncfusion object does something like that when we drop a docking
manager tool. It adds 3 new properties to every object that can use this
resources.

I tried to find information but maybe because I don't know how to call
that effect, I was not succesfull to find information.

Thank you very much.

Miky
*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: pablo | last post by:
Dear NewsGroupers, I am relatively new to OOP and cannet get my head around this problem. I have two classes. Class Child extends Parent. There is no constructor for the Child class. So when I...
2
by: manohar.shankar | last post by:
Hi, I have been searching on this topic for quite sometime and didnt get any answer. Is there a way I can extend/add methods/properties to a C# class during runtime. eg., I have class:...
9
by: James Geurts | last post by:
Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. ...
4
by: Richard Abraham | last post by:
I have created a new class ServiceTimer based upon the .NET System.Timers.Timer class. This has a new property CollectionIntervalMinutes which I expected to be added to the 'Behavior' section of the...
2
by: Tim Marsden | last post by:
Hi, This is what I am doing, please comment if this is the correct way. I need to add controls to a form dynamically. Within the Page_Load event (is not Postback) I run a routine to create the...
3
by: Dino M. Buljubasic | last post by:
Is it possible to add my own property to a control? For example, since MainMenu control does not have Background property, can I add my own and use it to set the color. Thank you, Dino --
3
by: cleo | last post by:
In VB6 my practice was to set control properties at Run Time rather than Design Time. I found setting property values in the code provided better documentation, since much of this was hidden - and...
2
by: Dennis | last post by:
I have a control which I wrote that has, of course, numerous properties. These properties nicely show up at design time in the property window for the user to set their value at design time. ...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.