【问题标题】:Identify the type of control selected on DiagramControl object识别在 DiagramControl 对象上选择的控件类型
【发布时间】:2020-03-21 17:01:27
【问题描述】:

我正在使用 devexpress 工具的 DiagramControl。当我添加形状时,在其上插入图像和文本字段。如何检测用户在其 SelectionChanged 事件中选择的控件类型? 当我使用 diagramControl.Items 数组迭代器时

for (int iControlIndex = 0; iControlIndex < diagControl1.Items.Count; iControlIndex++)
{    
    (diagControl1.Items[iControlIndex] as DiagramImage)
}

如果它的 DiagramImage 则它可以工作,但如果它是 DiagramShape 它会给出异常。 我需要在选定的形状项目上写一些类似 switch case 的东西,它在形状或图像或文本等情况下给出形状类型。

【问题讨论】:

    标签: c# devexpress devexpress-windows-ui


    【解决方案1】:

    你能试试这样的吗:

    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();
    }
    

    【讨论】:

      猜你喜欢
      • 2013-09-24
      • 2016-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-13
      • 1970-01-01
      • 1970-01-01
      • 2011-08-24
      相关资源
      最近更新 更多