windowsforms-devexpress-dot-xtradiagram-dot-diagramitem-536b459e.md
Gets or sets the coordinates of the item’s upper left corner relative to the diagram canvas.
Namespace : DevExpress.XtraDiagram
Assembly : DevExpress.XtraDiagram.v25.2.dll
NuGet Package : DevExpress.Win.Diagram
[CustomAction(typeof(ActionAffectsConnectorsRouting))]
[DefaultValue(typeof(PointFloat), "0,0")]
[DiagramCategory(DiagramCategory.Layout)]
public virtual PointFloat Position { get; set; }
<DefaultValue(GetType(PointFloat), "0,0")>
<DiagramCategory(DiagramCategory.Layout)>
<CustomAction(GetType(ActionAffectsConnectorsRouting))>
Public Overridable Property Position As PointFloat
| Type | Default | Description |
|---|---|---|
| PointFloat | "0,0" |
The coordinates of the item’s upper left corner.
|
For items within a container, the DiagramItem.Position property specifies the coordinates of the item’s upper left corner relative to the container.
The following code snippets (auto-collected from DevExpress Examples) contain references to the Position 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.
winforms-diagram-proportionally-resize-shapes-within-container/CS/WindowsFormsApp4/Form1.cs#L44
var containingRect = customContainer.Items.Select(x => x.RotatedDiagramBounds().BoundedRect()).Aggregate(Rect.Empty, Rect.Union);
customContainer.Position = new PointFloat((float)containingRect.X, (float)containingRect.Y);
customContainer.Width = (float)containingRect.Width;
winforms-diagram-create-rotatable-containers-with-shapes/CS/WindowsFormsApp4/Form1.cs#L43
var containingRect = container.Items.Select(x => x.RotatedDiagramBounds().BoundedRect()).Aggregate(Rect.Empty, Rect.Union);
container.Position = new PointFloat((float)containingRect.X, (float)containingRect.Y);
container.Width = (float)containingRect.Width;
How-to-execute-an-arbitrary-action-when-a-diagram-item-is-clicked-winforms/CS/DXSample/Form1.cs#L26
caption: "An item was clicked",
text: $"Item: {item.GetType()}{Environment.NewLine}Position: {item.Position}",
buttons: MessageBoxButtons.OK,
winforms-diagram-proportionally-resize-shapes-within-container/VB/WindowsFormsApp4/Form1.vb#L46
Dim containingRect = customContainer.Items.[Select](Function(x) x.RotatedDiagramBounds().BoundedRect()).Aggregate(Rect.Empty, New Func(Of Rect, Rect, Rect)(AddressOf Rect.Union))
customContainer.Position = New PointFloat(CSng(containingRect.X), CSng(containingRect.Y))
customContainer.Width = CSng(containingRect.Width)
winforms-diagram-create-rotatable-containers-with-shapes/VB/WindowsFormsApp4/Form1.vb#L47
Dim containingRect = container.Items.[Select](Function(x) x.RotatedDiagramBounds().BoundedRect()).Aggregate(Rect.Empty, New Func(Of Rect, Rect, Rect)(AddressOf Rect.Union))
container.Position = New PointFloat(CSng(containingRect.X), CSng(containingRect.Y))
container.Width = CSng(containingRect.Width)
How-to-execute-an-arbitrary-action-when-a-diagram-item-is-clicked-winforms/VB/DXSample/Form1.vb#L20
If CSharpImpl.__Assign(item, TryCast(clickedItem, DiagramItem)) IsNot Nothing Then
Call MessageBox.Show(owner:=Me, caption:="An item was clicked", text:=$"Item: {item.GetType()} {Environment.NewLine}Position: {item.Position}", buttons:=MessageBoxButtons.OK, icon:=MessageBoxIcon.Information)
End If
See Also