Reputation: 301
I am using DiagramControl of devexpress tools. When I add shape, insert images and text field on it. How do I detect the type of control which is selected by user on its SelectionChanged event? When I use diagramControl.Items array iterator
for (int iControlIndex = 0; iControlIndex < diagControl1.Items.Count; iControlIndex++)
{
(diagControl1.Items[iControlIndex] as DiagramImage)
}
if its DiagramImage then it works but if it is DiagramShape it gives exception. I need to write something like switch case on shape item selected which gives Shape type in cases like its Shape or Image or Text.
Upvotes: 0
Views: 129
Reputation: 1259
Can you just try something like this:
DiagramItem currentItem = diagControl1.Items[iControlIndex];
if (currentItem is DiagramShape)
{
// Do whatever for DiagramShape
(currentItem as DiagramShape).DoSomething();
}
else if (currentItem is DiagramConnector)
{
// Do whatever for DiagramConnector)
(currentItem as DiagramShape).DoSomething();
}
Upvotes: 1