Compartilhar via


HierarchyInfo.OnSelected Método

Definição

Ocorre quando o objeto derivado de HierarchyInfo é selecionado.

protected public:
 virtual bool OnSelected();
protected internal virtual bool OnSelected ();
abstract member OnSelected : unit -> bool
override this.OnSelected : unit -> bool
Protected Friend Overridable Function OnSelected () As Boolean

Retornos

true se o HierarchyInfo objeto foi selecionado com êxito; caso contrário, false. Quando esse método não é substituído, retorna true.

Exemplos

O exemplo a seguir implementa o método OnSelected. O exemplo adiciona um Select_tst comando ao menu de atalho e especifica o nome de exibição "Selecionar + Testar". Em seguida, o exemplo chama o OnSelected método quando o comando "Selecionar + Teste" é clicado ou quando o nó é selecionado.


/// GetTaskItems() is called every time the context menu is invoked.
public override System.Collections.ICollection GetTaskItems() {

    ArrayList items = new ArrayList();

    Image imgAsk = rLoadImg.loadImgs(SystemIcons.Asterisk, 16);
    Image imgErr = rLoadImg.loadImgs(SystemIcons.Error, 16);

    items.Add(new MethodTaskItem(
                "DisplayTime",       // Method Name
                "Show Time",        // Menu item Text
                "DemoCategory")    // Category
                );

    Person prs = new Person(66, "Joe", "Smith");
    MethodTaskItem mti_i = new MethodTaskItem(
                                    "InvTst",       // Method Name
                                    "Invoke Test",   // Menu item Text
                                    sDemoCat,       // Category
                                    "Tool Tip:SC",  // ToolTip non-functional
                                    imgAsk,          // Menu Icon
                                    prs);      // user data
    mti_i.CausesNavigation = false;
    traceMTI(mti_i);

    items.Add(mti_i);


    items.Add(new MethodTaskItem(
          "ShowCnt",       // Method Name
          "Show Count",   // Menu item Text
          sDemoCat,       // Category
          "Tool Tip:SC",  // ToolTip non-functional
          mti_i.Image)    // Menu Icon
          );

items.Add(new MethodTaskItem(
                   "Select_tst",
                   "Select + Test",
                   sDemoCat)
                   );
protected override bool OnSelected()
{

    TraceStateInfo();   // Send state info to Trace Listener
    if (_navSimp)
        return Navigate(typeof(DemoPage));

    return Connection.EndConfigurationManagement(typeof(DemoPage));
}

Comentários

Os aplicativos normalmente usarão a OnSelected substituição para chamar o Navigate método . Esse método deve retornar false quando a navegação for cancelada. A navegação arbitrária entre nós nem sempre é possível.

Aplica-se a