how to run msdn code

private:
void InitializeMyButton()
{
// Create and initialize a Button.
Button^ button1 = gcnew Button;

// Set the button to return a value of OK when clicked.
button1->DialogResult = ::DialogResult::OK;

// Add the button to the form.
Controls->Add( button1 );
}
is any one who can help me to run this msdn code
i found it in msdn library and tried in windows forms application
plz help
it should work in windows forms application when you drag a new button in your form double click on button in your Form1[Designer] and button click event will be created.
i have tried these msdn codes many times but result zero. plz any one run this code and give me a suggestion. plz don't reply if you can not help really to run this codes.
Topic archived. No new replies allowed.