In This Article

OwnerDrawMenuItem Class

Represents an owner-draw MenuItem with the new Windows menu appearance.

public class OwnerDrawMenuItem : MenuItem
Inheritance:
Object Object

Constructors

OwnerDrawMenuItem()

Initializes a new instance of the OwnerDrawMenuItem class.

public OwnerDrawMenuItem()

OwnerDrawMenuItem(String)

Initializes a new instance of the OwnerDrawMenuItem class.

public OwnerDrawMenuItem(string text)
Parameter Type Description
text String

The text displayed on the item.

OwnerDrawMenuItem(String, Boolean, EventHandler, Shortcut, Object)

Initializes a new instance of the OwnerDrawMenuItem class.

public OwnerDrawMenuItem(string text, bool isChecked, EventHandler onClick, Shortcut shortcut, object tag)
Parameter Type Description
text String

The text displayed on the item.

isChecked Boolean

Whether the item is checked.

onClick EventHandler

The EventHandler that handles the Click event for the menu item.

shortcut Shortcut

A Shortcut for the menu item.

tag Object

An object that provides context information.

OwnerDrawMenuItem(String, Image, EventHandler)

Initializes a new instance of the OwnerDrawMenuItem class.

public OwnerDrawMenuItem(string text, Image image, EventHandler onClick)
Parameter Type Description
text String

The text displayed on the item.

image Image

The image to display on the menu item.

onClick EventHandler

The EventHandler that handles the Click event for the menu item.

OwnerDrawMenuItem(String, EventHandler)

Initializes a new instance of the OwnerDrawMenuItem class.

public OwnerDrawMenuItem(string text, EventHandler onClick)
Parameter Type Description
text String

The text displayed on the item.

onClick EventHandler

The EventHandler that handles the Click event for the menu item.

OwnerDrawMenuItem(String, Int32)

Initializes a new instance of the OwnerDrawMenuItem class.

public OwnerDrawMenuItem(string text, int imageIndex)
Parameter Type Description
text String

The text displayed on the item.

imageIndex Int32

The index of an image within the parent ImageList.

OwnerDrawMenuItem(String, Int32, EventHandler, Shortcut, Object)

Initializes a new instance of the OwnerDrawMenuItem class.

public OwnerDrawMenuItem(string text, int imageIndex, EventHandler onClick, Shortcut shortcut, object tag)
Parameter Type Description
text String

The text displayed on the item.

imageIndex Int32

The index of an image within the parent ImageList.

onClick EventHandler

The EventHandler that handles the Click event for the menu item.

shortcut Shortcut

A Shortcut for the menu item.

tag Object

An object that provides context information.

OwnerDrawMenuItem(String, Shortcut)

Initializes a new instance of the OwnerDrawMenuItem class.

public OwnerDrawMenuItem(string text, Shortcut shortcut)
Parameter Type Description
text String

The text displayed on the item.

shortcut Shortcut

A Shortcut for the menu item.

Properties

CanAutoScaleImage

Gets or sets whether a drawn image can auto-scale based on DPI.

public bool CanAutoScaleImage { get; set; }

Property Value

Boolean:

true if a drawn image can auto-scale based on DPI; otherwise, false.

Image

Gets or sets the image to display on the menu item.

public Image Image { get; set; }

Property Value

Image:

The image to display on the menu item.

ImageIndex

Gets or sets the index of an image within the parent's ImageList to be displayed.

public int ImageIndex { get; set; }

Property Value

Int32:

The index of an image within the ImageList.

Remarks

This property should be set to -1 if no image is to be displayed on the item.

ShortcutText

Gets the proper display text of a shortcut.

public string ShortcutText { get; }

Property Value

String:

The proper display text of a shortcut.

Methods

OnDrawItem(DrawItemEventArgs)

Occurs when the OwnerDraw property of a menu item is set to true and a request is made to draw the menu item.

protected override void OnDrawItem(DrawItemEventArgs e)
Parameter Type Description
e DrawItemEventArgs

Event arguments

OnMeasureItem(MeasureItemEventArgs)

Occurs when the menu needs to know the size of a menu item before drawing it.

protected override void OnMeasureItem(MeasureItemEventArgs e)
Parameter Type Description
e MeasureItemEventArgs

Event arguments