[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...
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
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...
Re: How to declare the Sub from the Class?
Re: How to declare the Sub from the Class?
Quote:
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.
Quote:
Let it be useful to the searchers....
Thanks. :) Perhaps it would even be a bit more useful with code tags... ;)
Re: [RESOLVED] How to declare the Sub from the Class?
Thanks Eric.. I get clear...