-
April 16th, 2012, 01:43 AM
#1
[RESOLVED] How to declare the Sub from the Class?
I have a HeaderFile MyProject_Datas.h
//MyProject_Datas.h
public ref class MyUsefulDatas
{
blah...blah...blah...
public: static System::Void Item_Name( System::Object^ Sender, System::Windows::Forms::KeyEventArgs^ e) {
blah...blah...blah...
}
public: static System::Void Party_Name( System::Object^ Sender, System::Windows::Forms::KeyEventArgs^ e) {
blah...blah...blah...
}
};
And now from my Form2 - textBox2 I would like to declare
textBox2->KeyDown += gcnew KeyEventHandler(MyUsefulDatas, &MyUsefulDatas::Party_Name); ????????
Iam not getting the above line........
Also I would like to learn same statement, how to use in "delegate" statement like the below.....????
textBox2->KeyDown += delegate { .....???????? }
Thanks...
-
April 16th, 2012, 01:46 AM
#2
Re: How to declare the Sub from the Class?
You should post in the .NET forum instead. This forum is for native C++.
Edit: Sorry, the forum should be Managed C++ and C++/CLI
-
April 16th, 2012, 09:49 AM
#3
Re: How to declare the Sub from the Class?
After spending my whole day I found the crazier worth of the word, what is "static" ...
Also after removing the word "static" from the above declaration it works well..
Let it be useful to the searchers....
MyUsefulDatas^ MyUseDta=gcnew MyUsefulDatas;
textBox2->KeyDown += gcnew KeyEventHandler(MyUseDta, &MyUsefulDatas::Pty_NameCell);
Thanks...
-
April 16th, 2012, 10:29 AM
#4
Re: How to declare the Sub from the Class?
-
April 17th, 2012, 06:25 AM
#5
Re: How to declare the Sub from the Class?
Originally Posted by MAHEY
After spending my whole day I found the crazier worth of the word, what is "static" ...
Also after removing the word "static" from the above declaration it works well..
Mainly for the sake of completeness, now that it works, let me note that it is possible to attach static class member functions as event handlers; just the delegate construction syntax is different in this case:
Code:
textBox2->KeyDown += gcnew KeyEventHandler(MyUsefulDatas::Pty_NameCell);
Whether a static event handler actually makes more sense depends on the concrete scenario, of course.
Let it be useful to the searchers....
Thanks. Perhaps it would even be a bit more useful with code tags...
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
April 18th, 2012, 02:40 AM
#6
Re: [RESOLVED] How to declare the Sub from the Class?
Thanks Eric.. I get clear...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|