Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DiagramDataBindingControllerBase.UpdateItem Event

Occurs when a property of the data object represented by a diagram item has changed its value.

Namespace: DevExpress.XtraDiagram

Assembly: DevExpress.XtraDiagram.v24.2.dll

NuGet Package: DevExpress.Win.Diagram

#Declaration

public event EventHandler<DiagramUpdateItemEventArgs> UpdateItem

#Event Data

The UpdateItem event's data class is DevExpress.XtraDiagram.DiagramUpdateItemEventArgs.

#Remarks

The DataObject event’s property returns the data object whose property has changed its value. The Item event’s property returns the diagram item associated with the data object.

The example below illustrates how to handle the UpdateItem event to bind DiagramOrgChartController to DataSet.

private void diagramOrgChartController1_UpdateItem(object sender, DevExpress.XtraDiagram.DiagramUpdateItemEventArgs e) {
            var dataRow = e.DataObject as DataRowView;
            var container = e.Item as DiagramContainer;
            if (dataRow == null || container == null)
                return;
            foreach (var item in GetChildren(container)) {
                var binding = item.Bindings.FirstOrDefault();
                if (binding == null)
                    continue;
                try {
                    if (item is DiagramShape && binding.PropertyName == "Content")
                        ((DiagramShape)item).Content = dataRow[binding.Expression]?.ToString();
                    if (item is DiagramImage && binding.PropertyName == "Image")
                        ((DiagramImage)item).Image = dataRow[binding.Expression];
                }
                catch (ArgumentException) {}
            }
        }
        public IEnumerable<IDiagramItem> GetChildren(DiagramContainer container) {
            foreach (var item in container.Items) {
                yield return item;
                var childContainer = item as DiagramContainer;
                if (childContainer != null)
                    foreach (var childItem in GetChildren(childContainer))
                        yield return childItem;
            }
        }
See Also