windowsforms-devexpress-dot-xtramap-dot-mapoverlayitembase-ff61cca8.md
Gets or sets the alignment of the overlay item.
Namespace : DevExpress.XtraMap
Assembly : DevExpress.XtraMap.v25.2.dll
NuGet Package : DevExpress.Win.Map
[DefaultValue(ContentAlignment.TopLeft)]
public ContentAlignment Alignment { get; set; }
<DefaultValue(ContentAlignment.TopLeft)>
Public Property Alignment As ContentAlignment
| Type | Default | Description |
|---|---|---|
| ContentAlignment | TopLeft |
A ContentAlignment enumeration value.
|
You can use this property to align two or more items within the overlay. Note that, the overlay does not consider the item’s Alignment property then the Location property is set.
This example demonstrates how to implement a map overlay that looks like a button with an icon:
// In the Form_Load event handler.
MapOverlay overlay = CreateButtonLikeOverlay(
image: LoadOkIconFromResources(),
text: "OK"
);
overlay.Alignment = ContentAlignment.TopLeft;
overlay.Margin = new Padding(16);
mapControl1.Overlays.Add(overlay);
// ...
private MapOverlay CreateButtonLikeOverlay(Image image, String text) {
MapOverlay overlay = new MapOverlay();
overlay.Padding = new Padding(8);
overlay.Items.Add(new MapOverlayTextItem {
Text = text,
Alignment = ContentAlignment.MiddleRight
});
overlay.Items.Add(new MapOverlayImageItem {
Image = image,
Alignment = ContentAlignment.MiddleLeft
});
return overlay;
}
' In the Form_Load event handler.
Dim Resources As ComponentResourceManager = New ComponentResourceManager(GetType(Form1))
Dim overlay As MapOverlay = CreateButtonLikeOverlay(
image:=LoadOkIconFromResources(),
text:="OK"
)
overlay.Alignment = ContentAlignment.TopLeft
overlay.Margin = new Padding(16)
MapControl1.Overlays.Add(overlay)
' ...
Private Function CreateButtonLikeOverlay(image As Image, text As String) As MapOverlay
Dim overlay As MapOverlay = New MapOverlay()
overlay.Padding = new Padding(8)
overlay.Items.Add(New MapOverlayTextItem() With {
.Text = text,
.Alignment = ContentAlignment.MiddleRight
})
overlay.Items.Add(New MapOverlayImageItem With {
.Image = image,
.Alignment = ContentAlignment.MiddleLeft
})
Return overlay
End Function
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Alignment property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
copyrightImageItem.Image = Image.FromStream(stream);
copyrightImageItem.Alignment = ContentAlignment.MiddleLeft;
copyrightOverlay.Items.Add(copyrightImageItem);
copyrightImageItem.Image = Image.FromStream(stream)
copyrightImageItem.Alignment = ContentAlignment.MiddleLeft
copyrightOverlay.Items.Add(copyrightImageItem)
See Also