I have actually taken this a step further now and moved the context =
creation into the usercontol in the lampcreation procedure....thanks =
all...
--=20
--Eric Cathell, MCSA
[quoted text, click to view] "ECathell" <ecathell@nospam.com> wrote in message =
news:emw3UxLpFHA.3376@TK2MSFTNGP10.phx.gbl...
I have a control I am creating that will be used for several =
applications.
The control is a series of lights that have a status of active or =
paused. and they sit in a usercontrol container. The user control sits =
in different forms of various purpose. I have a context menu tied to the =
base lamp class that allows you to garner information about the object =
tied to that light for instance it could pull up the underlying =
information for editing, or another interface just for informational =
context. What I would like to do is depending on the application have =
different options in the context menus for the light. In one application =
I may only want the informational option, in a different application I =
may want both the edit function and the informational function. A =
different application may have totally different options.=20
In order to do this I know that I have to create the menus =
dynamically. Talking through this like this I think it would make more =
sense to do this within the usercontrol at instantiation by passing an =
application type to the constructor. Is that correct?=20
here is my code for the lamp. If my thinking is correct I would need =
to make setMenuOptions as public, passing in a configured menu item...
wow...talking this out with you all has been a big help....thanks =
all...hehe...
Maybe I need to type this stuff out more often...
Public Class lamp
Inherits Windows.Forms.Label
Private components As System.ComponentModel.IContainer
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents mnuItemFindLoad As System.Windows.Forms.MenuItem
Friend WithEvents mnuItemLoadInformation As =
System.Windows.Forms.MenuItem
Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
Private Sub InitializeComponent()
Me.components =3D New System.ComponentModel.Container
Me.ToolTip1 =3D New System.Windows.Forms.ToolTip(Me.components)
Me.ContextMenu1 =3D New System.Windows.Forms.ContextMenu
End Sub
Private m_loadno As Integer
Public Property LoadNumber() As Integer
Get
Return m_loadno
End Get
Set(ByVal Value As Integer)
m_loadno =3D Value
End Set
End Property
Public Sub New()
MyBase.New()
Me.Status =3D statusENUM.PAUSED
Me.BorderStyle =3D System.Windows.Forms.BorderStyle.FixedSingle
Me.Size =3D New System.Drawing.Size(25, 25)
End Sub
Public Enum statusENUM
ACTIVE
PAUSED
End Enum
Private m_status As statusENUM
Public Property Status() As statusENUM
Get
Return m_status
End Get
Set(ByVal Value As statusENUM)
m_status =3D Value
changelamp(Value)
End Set
End Property
Public Sub changelamp(ByVal status As statusENUM)
Me.ToolTip1 =3D New ToolTip
Me.ContextMenu1 =3D New ContextMenu
Select Case status
Case statusENUM.ACTIVE
Me.BackColor =3D Color.Lime
setToolTip(Me, Me.LoadNumber)
setMenuOptions()
Me.ContextMenu =3D Me.ContextMenu1
Case statusENUM.PAUSED
Me.BackColor =3D Color.Red
disableTooltip()
End Select
End Sub
Private Sub setToolTip(ByVal ctl As lamp, ByVal loadno As Integer)
Me.ToolTip1.SetToolTip(ctl, loadno)
End Sub
Private Sub disableTooltip()
Me.ToolTip1.Active =3D False
End Sub
Private Sub setMenuOptions()
Me.mnuItemFindLoad =3D New MenuItem
Me.mnuItemLoadInformation =3D New MenuItem
Me.mnuItemFindLoad.Text =3D "Edit Load"
Me.mnuItemLoadInformation.Text =3D "View Load Information"
Me.ContextMenu1.MenuItems.Add(0, Me.mnuItemFindLoad)
Me.ContextMenu1.MenuItems.Add(1, Me.mnuItemLoadInformation)
End Sub
=20
End Class
--=20