TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
huyen_linh_tu
NA
1
0
Reflection: invoke method on a form using its handle
Apr 20 2004 4:07 AM
1. I use the following to invoke a method on a form: private void InvokeMethod(Form form, string methodName, params object[] parms) { try { EventHandler eh = (EventHandler)Delegate.CreateDelegate(typeof (EventHandler), form, methodName); if (eh != null) { form.Invoke(eh, parms); } } catch(Exception ex) { MessageBox.Show(ex.Message); return; } } 2. The prerequisite for #1 is: try { testAssembly = Assembly.LoadFrom(textBox3.Text); Type t = testAssembly.GetType(textBox4.Text); testForm = (Form)testAssembly.CreateInstance(t.FullName); ThreadPool.QueueUserWorkItem(new WaitCallback(RunApp), testForm); } catch(Exception ex) { MessageBox.Show(ex.Message); } 3. What I need is invoking a method on a form that is running, i.e. skipping #2. I thought I could retrieve the handle to the running form, then by some cast invoke the wanted method. However, I am stuck. I have no idea how to go from a form's handle back to the form. 4. Please help.
Reply
Answers (
0
)
Game of Life..need some assistance...
how to:Authenticate,create users, upload download C++ programs, compile them and display back result