473,815 Members | 3,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1939
On 2007-11-05 06:46:03 -0800, "Rinaldo"
<zw************ *@hotmail.com.n ospamsaid:
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 BackgroundWorke r 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*********@Nn OwSlPiAnMk.coms chreef in bericht
news:2007110509 155650073-NpOeStPeAdM@NnO wSlPiAnMkcom...
On 2007-11-05 06:46:03 -0800, "Rinaldo"
<zw************ *@hotmail.com.n ospamsaid:
>I have a label on my dialogbox who has to change text while running. This
is what I do:

lblBackup.Te xt = "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 BackgroundWorke r 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.n ospamsaid:
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.DoE vents() 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: BackgroundWorke r 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
1808
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 from "OpenFileDialog" and then display it in a picturebox. This actually works properly before the button1 is clicked. Button1 is a button to open a new form and again it gets a panel returned from the static method inside "Coord" and perform the...
5
5874
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 that the user can use Alt+A, Alt+E etc etc when the screen loads, Add, Edit and Exit are enabled.
2
2649
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 sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles mnuOpen.DrawItem Dim Ic As New Icon(Application.StartupPath & "\101_72.ico") DrawItems(e, mnuOpen, Ic) End Sub
0
1742
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 app and moved it to another computer and I get the following error msg when I load the form with the mediaplayer on it. I upgraded this project from a standard vb app to the .net version (vb express anyway) and that is when the problem arose. ...
6
2283
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 the same method (aka delegate?). I use the Tag property within this method to determine what user action is taking place. Very simple: When adding toolbar button: tbButton.Click += new...
0
1486
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 bottom the last item remains almost nvisable. What is the matter? using System; using System.Collections.Generic;
2
2490
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 statements from the top of my own program which were out of order): using System; using System.ComponentModel;
4
2002
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 has this to do with networking? Before I get burned to the stake, please hear me out. I have recently plugged a wireless router on my (wireless) modem because my modem could only be configured as a DHCP server and was not able to forward any traffic...
4
3351
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 . rt now im not sure where the problem is . is it something to do with any dll file which i need to include. if yes could u suggest me which dll files are involved in the open file dialog? thank u in advance See the end of this message for...
0
10670
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10408
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10426
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3886
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3030
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.