Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Menu -Help ?

Menu -Help ?

Scheduled Pinned Locked Moved Visual Basic
questioncsharphelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 765502
    wrote on last edited by
    #1

    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

    E 1 Reply Last reply
    0
    • U User 765502

      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

      E Offline
      E Offline
      elRaptor
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups