PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Adding a "Title" to a context menu

 
 
JB
Guest
Posts: n/a
 
      15th Apr 2010
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
 
Reply With Quote
 
 
 
 
PvdG42
Guest
Posts: n/a
 
      16th Apr 2010

"JB" <(E-Mail Removed)> wrote in message
news:543d8c59-e5a4-4725-8e20-(E-Mail Removed)...
> 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 :-)


 
Reply With Quote
 
AMercer
Guest
Posts: n/a
 
      16th Apr 2010
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.


"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
> .
>

 
Reply With Quote
 
Phill W.
Guest
Posts: n/a
 
      19th Apr 2010
On 16/04/2010 00:18, PvdG42 wrote:
>
> "JB" <(E-Mail Removed)> wrote in message
> news:543d8c59-e5a4-4725-8e20-(E-Mail Removed)...
>> 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 :-)


I cannot remember where I found this on the web (apologies to the
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove "Edit", "Print", "Preview" from context menu? =?Utf-8?B?TW8=?= Windows XP General 8 4th Nov 2006 04:44 AM
Remove "Edit", "Print", "Preview" from context menu =?Utf-8?B?TW8=?= Windows XP General 0 3rd Nov 2006 04:12 AM
Having trouble adding program to "Open With" context menu option Scott Hidalgo Windows XP Customization 0 2nd Mar 2005 09:12 PM
The "Manage" option has disappeared from the context menu when I right-click on "My Computer" Warren Massey Windows XP General 3 24th Aug 2004 09:45 PM
adding extra option to "send to" context menu dave Microsoft Windows 2000 Setup 1 17th Oct 2003 04:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:56 AM.