Home » C# ProgrammingRSS

writing messages to textBox

i have created a windows form application which includes a from and a class .

the form include a textBox to whom i'm writing messages through some process.

Form1.cs looks someting like this -

public

 

delegatevoidsetStatusCallBack(String str);

 

publicvoid setStatus(String str)

{

txtControl.Text = 

str;

}

private void someMethod()

{

setStatus(

"start.");

Class1 cls=new Class1();

cls.OtherMethod();

}

 

and Class1 looks like-

class Class1

{

 

privatesetStatusCallBack callback;

public void OtherMethod()

{ //doing something

callback("some message");

}

 

the problem is that all the messages appears in the textBox after the application finish to do everything.

i wan't the messages to appears through the process.

meaning i want first thing to see the message "start." and the the application to do it's work and only then to see "some message".

how can  i do that? why it's not working as it is?

thanks in advance. 

 

4 Answers Found

 

Answer 1

Welcome to MSDN Forums.

You can use Application.DoEvents (http://msdn.microsoft.com/en-us/library/system.windows.forms.application.doevents.aspx) whenever you need to refresh GUI.

Regards,

Yasser.

 

Answer 2

I am not very sure about this but can you try this:

 

publicvoidsetStatus(Stringstr)

{

txtControl.Text = 

str;

txtControl.Update();

}


 

Answer 3

thanks , it's working now
 

Answer 4

You are most welcome :)

Please mark the post an answer that solved your issue.

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter