Back to Devexpress

DiagramItem.Width Property

windowsforms-devexpress-dot-xtradiagram-dot-diagramitem-bcd6050e.md

latest6.0 KB
Original Source

DiagramItem.Width Property

Gets or sets the item width.

Namespace : DevExpress.XtraDiagram

Assembly : DevExpress.XtraDiagram.v25.2.dll

NuGet Package : DevExpress.Win.Diagram

Declaration

csharp
[DXCategory("Layout")]
[Browsable(false)]
public virtual float Width { get; set; }
vb
<DXCategory("Layout")>
<Browsable(False)>
Public Overridable Property Width As Single

Property Value

TypeDescription
Single

A Single value, specifying the item width in pixels.

|

The following code snippets (auto-collected from DevExpress Examples) contain references to the Width 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.

how-to-use-the-customdrawitem-event-to-draw-custom-icons-inside-diagram-items-t441104/CS/XtraDiagram.CustomDraw/Form1.cs#L44

csharp
var margin = 3f;
e.Graphics.DrawImage(image, new RectangleF(shape.Width - image.Width - margin, shape.Height - image.Height - margin, image.Width, image.Height));
e.Handled = true;

winforms-diagram-proportionally-resize-shapes-within-container/CS/WindowsFormsApp4/Form1.cs#L45

csharp
customContainer.Position = new PointFloat((float)containingRect.X, (float)containingRect.Y);
customContainer.Width = (float)containingRect.Width;
customContainer.Height = (float)containingRect.Height;

winforms-diagram-create-rotatable-containers-with-shapes/CS/WindowsFormsApp4/Form1.cs#L44

csharp
container.Position = new PointFloat((float)containingRect.X, (float)containingRect.Y);
container.Width = (float)containingRect.Width;
container.Height = (float)containingRect.Height;

winforms-diagram-track-and-restrict-drag-actions/CS/WinApp7/Form1.cs#L52

csharp
if (item.Item is DiagramShape shape && shape.Shape == BasicShapes.Pentagon) {
    var itemRect = new System.Windows.Rect(new System.Windows.Point(item.NewDiagramPosition.X, item.NewDiagramPosition.Y), new System.Windows.Size(item.Item.Width, item.Item.Height));
    foreach (var diagramShape in diagramControl1.Items.OfType<DiagramShape>().Where(x => x != shape)) {

winforms-diagram-create-custom-toolbox/CS/CustomDiagramToolboxExample/Form1.cs#L44

csharp
e.Cache.TranslateTransform(e.Bounds.X, e.Bounds.Y);
shapeItem.Width = 40;
shapeItem.Height = e.Bounds.Height;

how-to-use-the-customdrawitem-event-to-draw-custom-icons-inside-diagram-items-t441104/VB/XtraDiagram.CustomDraw/Form1.vb#L40

vb
Dim margin = 3F
e.Graphics.DrawImage(image, New RectangleF(shape.Width - image.Width - margin, shape.Height - image.Height - margin, image.Width, image.Height))
e.Handled = True

winforms-diagram-proportionally-resize-shapes-within-container/VB/WindowsFormsApp4/Form1.vb#L47

vb
customContainer.Position = New PointFloat(CSng(containingRect.X), CSng(containingRect.Y))
customContainer.Width = CSng(containingRect.Width)
customContainer.Height = CSng(containingRect.Height)

winforms-diagram-create-rotatable-containers-with-shapes/VB/WindowsFormsApp4/Form1.vb#L48

vb
container.Position = New PointFloat(CSng(containingRect.X), CSng(containingRect.Y))
container.Width = CSng(containingRect.Width)
container.Height = CSng(containingRect.Height)

winforms-diagram-create-custom-toolbox/VB/CustomDiagramToolboxExample/Form1.vb#L45

vb
e.Cache.TranslateTransform(e.Bounds.X, e.Bounds.Y)
shapeItem.Width = 40
shapeItem.Height = e.Bounds.Height

See Also

Height

Size

DiagramItem Class

DiagramItem Members

DevExpress.XtraDiagram Namespace