none
popupmenu RRS feed

  • Question

  • Hi

     

    I was creating a popupmenu like following.

     

    // popupmenu

    this->Components = (gcnew System::ComponentModel::Container());

    this->ContextMenuStrip1 = (gcnew System::Windows::Forms::ContextMenuStrip(this->Components));

    this->CutTSMI = (gcnew System::Windows::Forms::ToolStripMenuItem());

    this->CopyTSMI= (gcnew System::Windows::Forms::ToolStripMenuItem());

    this->toolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripSeparator());

    this->PasteTSMI = (gcnew System::Windows::Forms::ToolStripMenuItem());

    this->ContextMenuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->CutTSMI,

    this->CopyTSMI,this->toolStripMenuItem1,this->PasteTSMI});

    this->ContextMenuStrip1->Name = L"contextMenuStrip1";

    //Cut

    this->CutTSMI->Name = L"cut";

    this->CutTSMI->Size = System:Big Smilerawing:Tongue Tiedize(152, 22);

    this->CutTSMI->Text = L"Cu&t";

    this->CutTSMI->Click += gcnew System::EventHandler(this, &Mform::cutToolStripMenuItem_Click);

    //copy

    this->CopyTSMI->Name = L"copyToolStripMenuItem";

    this->CopyTSMI->Size = System:Big Smilerawing:Tongue Tiedize(152, 22);

    this->CopyTSMI->Text = L"&Copy";

    this->CopyTSMI->Click += gcnew System::EventHandler(this, &Mform::copyToolStripMenuItem_Click);

     

    for this how to apply the TrackPopupMenu() .

     

    Guide me.

     

    Thanks

     

     

     

     

    Wednesday, February 20, 2008 9:48 AM

Answers

  • Use ContextMenuStrip1->Show method to show context menu. You can set the place in the Point parameter and parent control. The best place to do this is in the MouseDown or MouseUp event handler of the form.

     

    Wednesday, February 20, 2008 3:00 PM