473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Strange problem drawing text in a dialog

Hi,

I have a label on my dialogbox who has to change text while running. This is
what I do:

lblBackup.Text = "Bezig met de backup naar " + F1.FTPserver;

but the text does'nt appear, only if I draw (call) a messagebox, then the
text appears. What can it be? I had made a total new one, but did'nt help.

Rinaldo

Nov 5 '07 #1
3 1913
On 2007-11-05 06:46:03 -0800, "Rinaldo"
<zw*************@hotmail.com.nospamsaid:
I have a label on my dialogbox who has to change text while running.
This is what I do:

lblBackup.Text = "Bezig met de backup naar " + F1.FTPserver;

but the text does'nt appear, only if I draw (call) a messagebox, then
the text appears. What can it be? I had made a total new one, but
did'nt help.
If I had to guess (and I do, because you didn't post nearly enough code
to illustrate what you're actually doing), I'd guess that you are in
some sort of processing loop in which you change the Text property of
the Label and that processing loop is in the main UI thread.

If that's the case, then until the processing loop has completed and
whatever UI method started the processing loop returns, nothing in your
UI will be able to redraw itself, including the Label that you've
changed.

If you have a lengthy processing to do and you have a need for the UI
to remain responsive (including redrawing when you update it), then you
need to put the processing into a different thread so that the UI can
update itself when necessary.

The BackgroundWorker class is ideal for simple examples of this sort of
situation. You can use it to run your processing, and from the
processing code use the Control.Invoke() method to execute code that
will update the UI. Then the UI changes will actually be visible to
the user while the processing goes on.

Pete

Nov 5 '07 #2
Hi pete,

The strange thing was that it suddenly stopped. It was because it did'nt
redraw the dialog, but a this.Refresh() worked. I do'nt know why it stopped
to work.

Thanx for your excelent explanation, but I have just yet another bunch of
questions, I am a beginner. I formally programmed C, but that's 20 years
ago.

"Peter Duniho" <Np*********@NnOwSlPiAnMk.comschreef in bericht
news:2007110509155650073-NpOeStPeAdM@NnOwSlPiAnMkcom...
On 2007-11-05 06:46:03 -0800, "Rinaldo"
<zw*************@hotmail.com.nospamsaid:
>I have a label on my dialogbox who has to change text while running. This
is what I do:

lblBackup.Text = "Bezig met de backup naar " + F1.FTPserver;

but the text does'nt appear, only if I draw (call) a messagebox, then the
text appears. What can it be? I had made a total new one, but did'nt
help.

If I had to guess (and I do, because you didn't post nearly enough code to
illustrate what you're actually doing), I'd guess that you are in some
sort of processing loop in which you change the Text property of the Label
and that processing loop is in the main UI thread.

If that's the case, then until the processing loop has completed and
whatever UI method started the processing loop returns, nothing in your UI
will be able to redraw itself, including the Label that you've changed.

If you have a lengthy processing to do and you have a need for the UI to
remain responsive (including redrawing when you update it), then you need
to put the processing into a different thread so that the UI can update
itself when necessary.

The BackgroundWorker class is ideal for simple examples of this sort of
situation. You can use it to run your processing, and from the processing
code use the Control.Invoke() method to execute code that will update the
UI. Then the UI changes will actually be visible to the user while the
processing goes on.

Pete

Nov 5 '07 #3
On 2007-11-05 10:35:10 -0800, "Rinaldo"
<zw*************@hotmail.com.nospamsaid:
The strange thing was that it suddenly stopped. It was because it
did'nt redraw the dialog, but a this.Refresh() worked. I do'nt know why
it stopped to work.
Don't use Refresh(). It's a hack. If calling Refresh() causes the
update to happen, then it's almost certain that the problem is exactly
as I described and should be solved in the way I describe, rather than
calling Refresh() or related methods (e.g. don't call Control.Update()
or Application.DoEvents() either).
Thanx for your excelent explanation, but I have just yet another bunch
of questions, I am a beginner. I formally programmed C, but that's 20
years ago.
Well, that's what the newsgroup is for. To answer questions. :) So
fire away...

That said, there are numbers of threads already discussing the
fundamental concepts raised here: BackgroundWorker and
Control.Invoke(). Google Groups will help you find those. It's
entirely possible that any question you might have has already been
asked and answered here, so you should check the archives before
posting new questions.

Pete

Nov 5 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: chau_fai | last post by:
I have a window Form called "Form2". There is only one button and a panel returned from a static method of the "Coord" in this form. In the panel returned, there is a button that can choose image...
5
by: Edwinah63 | last post by:
Hi everyone, i was wondering if anyone else had observed this and if there is any workaround i have a screen (an mdi child form) with the buttons &Add, &Edit, &Save and E&xit, the idea being...
2
by: Piedro | last post by:
Can someone reproduce the following error? I'm using the module at the bottom of my post to owner draw a menu items, I call the module from a form like this: Private Sub mnuOpen_DrawItem(ByVal...
0
by: Nonee | last post by:
Hello- I have a form with the mediaplayer referenced to play mp3's and avi's and I believe that is what is causing the problem. I am not sure, but I am hoping. Anyway, I "published" the vb.net...
6
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to...
0
by: Christof Nordiek | last post by:
Hi, Below is a simple program that demonstrates my poblem. i fill a treeview with nine nodes. Then the treeview is shown with a scrollbar. But I can't scroll to the last item. scrolling to the...
2
by: escher4096 | last post by:
Hi all, In C# 2.0, if I take a set of strings and toss them into an ArrayList and then sort them it does not always work as expected. I used some garbage data (I just grabbed the using...
4
prometheuzz
by: prometheuzz | last post by:
Hello all, There's this problem I have, which I am unable to find a solution for. The problem is this: I cannot post messages with a specific size on (certain) forums. I hear you thinking: what...
4
by: nightscorpion | last post by:
Hello Gurus, i implemented the OpenFileDialog in my Windows Form Applications and it worked perfectly fine.However when it was run on a remote desktop i got the below error . ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.