|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Adding a "Title" to a context menuHi All,
I wonder if there's a way to add some sort of title to a context menu. A bit like message box titles for instance. Thanks JB "JB" <jb.bross***@gmail.com> wrote in message Not that I'm aware of, or that is readily apparent from looking at the news:543d8c59-e5a4-4725-8e20-7202a04de8c4@g11g2000yqe.googlegroups.com... > Hi All, > > I wonder if there's a way to add some sort of title to a context menu. > A bit like message box titles for instance. > > Thanks > JB ContextMenuStrip class members in MSDN. http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip_members(v=VS.100).aspx That said, it's an interesting question, and I look forward to being corrected :-) On 16/04/2010 00:18, PvdG42 wrote:
Show quoteHide quote > I cannot remember where I found this on the web (apologies to the > "JB" <jb.bross***@gmail.com> wrote in message > news:543d8c59-e5a4-4725-8e20-7202a04de8c4@g11g2000yqe.googlegroups.com... >> Hi All, >> >> I wonder if there's a way to add some sort of title to a context menu. >> A bit like message box titles for instance. >> >> Thanks >> JB > > Not that I'm aware of, or that is readily apparent from looking at the > ContextMenuStrip class members in MSDN. > > http://msdn.microsoft.com/en-us/library/system.windows.forms.contextmenustrip_members(v=VS.100).aspx > > > That said, it's an interesting question, and I look forward to being > corrected :-) author) but these are the building blocks that I use to do this particular job. ''' <summary> ''' ContextMenuStrip with a non-clickable "header" bar ''' </summary> ''' <remarks> ''' <para> ''' We needed this sub-class of ''' <see cref="T:System.Windows.Forms.ContextMenuStrip" /> because the original automatically hides the menu when any item is clicked. ''' </para> ''' <para> ''' Given that our header item doesn't want this behaviour, we have to not only extend the ''' <see cref="T:System.Window.Forms.ToolStripMenuitem" /> itself, but also its containing ''' <see cref="T:System.Window.Forms.ContextMenuStrip" />. ''' </para> ''' </remarks> Friend Class HeadedContextMenuStrip Inherits ContextMenuStrip Public Sub New( container as IContainer ) MyBase.New( container ) End Sub Protected Overrides Sub OnItemClicked( e as ToolStripItemClickedEventArgs ) { If Not ( TypeOf e.ClickedItem Is ContextMenuHeader ) Then MyBase.OnItemClicked( e ) End If End Property End Class ''' <summary> ''' Header item to be used in conjunction with the HeadedContextMenuStrip. ''' </summary> Friend Class ContextMenuHeader Inherits ToolStripMenuItem Private Sub New() MyBase.New() End Sub Public Sub New( text as String ) MyBase,New( text ) Me.BackColor = SystemColors.GradientInactiveCaption Me.Font = New Font(Me.Font, FontStyle.Bold) Me.ForeColor = SystemColors.MenuText End Sub Protected Overrides Function CreateDefaultDropDown() as ToolStripDropDown ToolStripDropDownMenu menu = New ToolStripDropDownMenu() menu.OwnerItem = Me return menu End Function Protected Overrides ReadOnly Property DismissWhenClicked() as Boolean Get Return False End Get End Property End Class HTH, Phill W. I haven't tried this, but maybe you can get something from a new, specially
formatted MenuItem at the top of your menu. Maybe an owner drawn MenuItem with the title displayed in sufficient contrast to the real MenuItems. Or, maybe you can put the title text in an image and use MenuItem.ImageUrl to display it. If you have the time and energy to investigate, please post back your results. Show quoteHide quote "JB" wrote: > Hi All, > > I wonder if there's a way to add some sort of title to a context menu. > A bit like message box titles for instance. > > Thanks > JB > . >
Removing the beep
Button calling aother button's code How to set the Tab size in a TextBox Control Bug outside IDE only in Release mode DateGridView NRE Error how to capture a photo from my web cam ? communication between two vb apps Refer to childs of user control. Re: JPG Processing in .NET Help for populate Chart |
|||||||||||||||||||||||