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.1.dll
NuGet Package: DevExpress.Win.Diagram
Declaration
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