tomster71

Access to Controls on PB display

Discussion created by tomster71 on Aug 5, 2009
Latest reply on Aug 18, 2009 by mlemley

I have tried to access the controls MDBTree and BatchView on a PB display by a PB Add-In.  I am able to get the controls in the PB.Symbols collection but do not know how to cast them the appropriate data type. To demonstrate the problem i submit a sample code (C#/VS2008). The code work for the symbol type pbSymbolTrend but not for pbSymbolControl and pbSymbolBTrend.

 

Any hint how to access these two controls (catching events, calling methods, reading/writing properties) are welcome.

private void OnDisplayActivate(Display aDisplay)
{
    try
    {
        SymbolClass symb = null;
        try {
            symb = (SymbolClass)aDisplay.Symbols.Item("MDBTree1");
        }
        catch (Exception ex) {
            symb = null;
        }
        if (symb == null || symb.Type != (int) PBSymLib.pbSYMBOLTYPE.pbSymbolControl)
            return;

        try
        {
            PBControl cont = (PBControl)symb;
            MessageBox.Show("Type PBControl OK");
        }
        catch (Exception ex)
        {
            MessageBox.Show("dont know the type for PBControl");
        }

        try
        {
            symb = (SymbolClass)aDisplay.Symbols.Item("Trend1");
        }
        catch (Exception ex) {
             symb = null;
        }
        if (symb == null || symb.Type != (int)PBSymLib.pbSYMBOLTYPE.pbSymbolTrend)
            return;

        try
        {
            PBSymLib.Trend trend = (PBSymLib.Trend)symb;
            MessageBox.Show("Type Trend OK");
        }
        catch (Exception ex)
        {
            MessageBox.Show("dont know the type for Trend");
        }

        try
        {
            symb = (SymbolClass)aDisplay.Symbols.Item("BatchGroup1");
        }
        catch (Exception ex) {
            symb = null;
        }
        if (symb == null || symb.Type != (int)PBSymLib.pbSYMBOLTYPE.pbSymbolBTrend)
            return;

        MessageBox.Show("dont know the type for BTrend");

        // else
    }
    catch (Exception ex)
    {
        MessageBox.Show("Exception in OnDisplayActivate: " + ex.Message);
    }
}

Outcomes