Menu -Help ?
-
Hi ,i have developed an app in .NET,and have to use MENU. I need to add images in the menu bar.how can i do this? If any one know ,please help me ........... Thanxs in Advance shihab R M
-
Hi ,i have developed an app in .NET,and have to use MENU. I need to add images in the menu bar.how can i do this? If any one know ,please help me ........... Thanxs in Advance shihab R M
Hello again: I have use a component class that inherits from the MenuItem class: this is the class: Imports System.ComponentModel _ Public Class MiMenuItem Inherits MenuItem Private mFont As Font = SystemInformation.MenuFont Private mImage As System.Drawing.Image = Nothing Private nStartTextPosition As Integer = 0 Public Sub New() MyBase.New() End Sub _ Property StartTextPosition() As Integer Get StartTextPosition = nStartTextPosition End Get Set(ByVal Value As Integer) nStartTextPosition = Value End Set End Property Property Font() As System.Drawing.Font Get Font = mFont End Get Set(ByVal Value As Font) mFont = Value End Set End Property Property Image() As Image Get Image = mImage End Get Set(ByVal Value As Image) mImage = Value End Set End Property Protected Overrides Sub OnMeasureItem(ByVal e As System.Windows.Forms.MeasureItemEventArgs) Dim itemSize As SizeF itemSize = e.Graphics.MeasureString(Me.Text, mFont) Dim nIconW As Integer = 0 Dim nIconH As Integer = 0 If Not (mImage Is Nothing) Then nIconW = mImage.Width If mImage.Height > itemSize.Height Then nIconH = mImage.Height - itemSize.Height End If e.ItemWidth = itemSize.Width + nIconW + nStartTextPosition e.ItemHeight = itemSize.Height + nIconH End Sub Protected Overrides Sub OnDrawItem(ByVal e As System.Windows.Forms.DrawItemEventArgs) Dim selected As Boolean Dim textcolor As Color = SystemColors.MenuText Dim textformat As New StringFormat() textformat.HotkeyPrefix = Drawing.Text.HotkeyPrefix.Show Dim nIconW As Integer = 0 If Not (mImage Is Nothing) Then nIconW = mImage.Width End If Dim R As New RectangleF(e.Bounds.Left + nIconW, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height) selected = (e.State And DrawItemState.Selected) e