Solved

Need to update textbox on the main form from another class

Posted on 2008-10-07
6
2,076 Views
Last Modified: 2013-12-17
I have a windows application form which has a textbox. I need to update the textbox on the main form from another class.
If I have a  button and textbox.when I click the button, it creates an object of another class and calls the method of the class. Asthe method is running it is looping through rows. It sends a message as it completes each row. I want that message to be displayed in th textbox.
Do we need to use delegates??/
Can you please provide me a solution for this.
0
Comment
Question by:MRManthani
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 22664059
You would need an instance of the main form, and then set the Modifiers to internal for the TextBox.
0
 

Author Comment

by:MRManthani
ID: 22664118
I have created instance of the main from.It is sending the messages.but the form gets frozen. I am not able to see it. it may be because the application is still running.
is there any way to see it updating when the application is running.
0
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22666235
yes delegates and events is the way to go in this scenario

create a delegate and an event in childclass

public delegate void SearchDelegate (string screenName, string parameter);
public event SearchDelegate SearchEvent;

in the method that you call add this
if (SearchEvent != null)
{
     SearchEvent ();
}

in the main form subscribe to the event as (just an idea)
this.childclass1.SearchEvent += new childclass.SearchDelegate(ShowScreen);

this will call your function and then you can handle your cases accordingly
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22666328
you need to pass the string value which u need to update to the text box in the delegate and then use that in the main form
0

Featured Post

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question