开发者

event handling for button click in visual c++

I want to retrive the data from a开发者_如何学Go textfield on the click of a button.


  1. Add a new project of type "Visual C++/CLR/Windows Forms Application" to your solution.

  2. Add a button and textbox to the designer.

  3. Double-click the button on the designer. This should take you to the form code, where an event handler will have been created and registered for you.

  4. In the body of that event handler, you may access the text field using its name from the design (the name is viewed/modified by right-clicking the item in the form designer and selecting "Properties").

Edit: I typically don't use C++ for Windows Forms applications, but this example seems to work:

 private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
             System::String^ txt = this->textBox1->Text;
             txt += " augmented";
             this->textBox1->Text = txt;
           }


private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)      
{           
    label1 -> Text= "Hello Yashan";  
}

this is ok

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜