473,799 Members | 3,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change status bar text back to default 5 seconds after every change?

Hi,

I'm using StatusBar text to inform the user what's going on in the
application. I pass a reference to from the main form's class to other
(instances of) classes that are doing the actual work, and they update
the Text property in various ways.

It would be slick (imo) if, after the user is informed about the antics
of some class-instance, if the StatusBar text would revert back to some
default text-variable in the main form class after some specified
interval of time (like 5 seconds).

Problem is, that I can't use the StatusBar's OnChange event (or
whatever's it's called) - if I did, then every time the "reversion" was
perform, the event would fire again.

So how would I go about implementing this? Even just a skeleton
code-example would be helpful.
Thanks for any ideas,

cdj

Nov 13 '06 #1
4 2184
Have not tried but you might be able to over load the status bar class and
add you on update event to change the text, something like SetTextTimed.
Save the old text, set a timer, and when the timer fired revert to the saved
text. You can debug it.

public class MyStatusBar : StatusBar
{
private string OldText = string.Empty;
private System.Windows. Forms.Timer timer;

public MyStatusBar()
: base()
{
timer = new System.Windows. Forms.Timer();
timer.Tick += new EventHandler(ti mer_Tick);
}

void timer_Tick(obje ct sender, EventArgs e)
{
this.text = this.OldText;
}

public void SetTextTimed(st ring text)
{
this.timer.Stop ();
this.OldText = this.Text;
this.Text = text;
this.timer.Inte rval = 5000;
this.timer.Star t();
}
}

Regards,
John

"sherifffruitfl y" <sh************ *@gmail.comwrot e in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Hi,

I'm using StatusBar text to inform the user what's going on in the
application. I pass a reference to from the main form's class to other
(instances of) classes that are doing the actual work, and they update
the Text property in various ways.

It would be slick (imo) if, after the user is informed about the antics
of some class-instance, if the StatusBar text would revert back to some
default text-variable in the main form class after some specified
interval of time (like 5 seconds).

Problem is, that I can't use the StatusBar's OnChange event (or
whatever's it's called) - if I did, then every time the "reversion" was
perform, the event would fire again.

So how would I go about implementing this? Even just a skeleton
code-example would be helpful.
Thanks for any ideas,

cdj

Nov 13 '06 #2
cdj,

Create a custom control. Inside it, do what you're currently doing. I
assume you're doing something like using OnChange to start a timer and
using the timer's callback to reset the status bar's data. To prevent
the endless loop, add a boolean member variable. Try this:

public class myControl : StatusBar
{

private boolean bDefault = true;
private Timer timeReset = new Timer(...);

public void OnChange(...)
{
if (!this.bDefault )
this.timeReset. Reset();
}

public void OnTimerTick(... )
{
this.bDefault = true;
// set text back to default
Text = "Ready.";
}

public void SetText(string text)
{
this.bDefault = false;
Text = text;
}

}

I don't guarantee this code compiles, it's more to demonstrate a point.
You probably want to use a property override instead of SetText(), but
I wrote it that way for clarity. Also, I've not dealt with thread
safety.
Stephan

sherifffruitfly wrote:
Hi,

I'm using StatusBar text to inform the user what's going on in the
application. I pass a reference to from the main form's class to other
(instances of) classes that are doing the actual work, and they update
the Text property in various ways.

It would be slick (imo) if, after the user is informed about the antics
of some class-instance, if the StatusBar text would revert back to some
default text-variable in the main form class after some specified
interval of time (like 5 seconds).

Problem is, that I can't use the StatusBar's OnChange event (or
whatever's it's called) - if I did, then every time the "reversion" was
perform, the event would fire again.

So how would I go about implementing this? Even just a skeleton
code-example would be helpful.
Thanks for any ideas,

cdj
Nov 13 '06 #3
I don't guarantee this code compiles, it's more to demonstrate a point.
You probably want to use a property override instead of SetText(), but
I wrote it that way for clarity. Also, I've not dealt with thread
safety.
Stephan
Stephan - thanks for the approach - I'll give it a shot!

So I get the idea that, in general terms, when you want a control to
have a lil more functionality than it currently has, you just derive
off of it, and code up the functionality you're after - is that right
in general?

Thanks again,

cdj

Nov 13 '06 #4
cdj,

Yes, that's the general idea. It's neater if you encapsulate it in a
new control. Even better, it makes it so much easier to use it in your
other forms and projects.

Another way to do this without inheriting is to create a new control,
place a status bar in it, and build a fascade for it. That gives much
more control over the status bar, but also forces you to implement a
whole bunch of stuff yourself. Which implementation is best for you
usually depends on things like time and budget, although sometimes also
just on your personal interest in going through the exercise.
Stephan
sherifffruitfly wrote:
I don't guarantee this code compiles, it's more to demonstrate a point.
You probably want to use a property override instead of SetText(), but
I wrote it that way for clarity. Also, I've not dealt with thread
safety.
Stephan

Stephan - thanks for the approach - I'll give it a shot!

So I get the idea that, in general terms, when you want a control to
have a lil more functionality than it currently has, you just derive
off of it, and code up the functionality you're after - is that right
in general?

Thanks again,

cdj
Nov 13 '06 #5

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

Similar topics

14
2522
by: Reply Via Newsgroup | last post by:
Folks, Say I have a table, ten columns, ten rows - Each with a word in it. I want to change the values of some/all of the cells in the table via a hyperlink. How do I reference each cell and change its text contents from a link elsewhere in the page? I have a rought idea that I'll need something like 'id' in my <td> tags but while I have a greater understanding of server-side programming langauges like PHP, javascript is still very new...
1
1076
by: Hardy Wang | last post by:
Hi, Guys I am currently working with a multi-language project, and I have a question, is System.Text.Encoding.Default related to machine (locale English, French, Chinese and etc) or independent? Say, I have different language OS (Win2000 Server), does System.Text.Encoding.Default.CodePage always return same value under different OS? Thanks! --
1
2793
by: gan | last post by:
I created a ASP.NET web setup project with the project name "Setup". I noticed that this name will be used as the default Virtual Directory name during deployment. I'd like to know whether we can change this default value while preserving the project name? Thanks in advance
13
4970
by: sonald | last post by:
Hi, Can anybody tell me how to change the text delimiter in FastCSV Parser ? By default the text delimiter is double quotes(") I want to change it to anything else... say a pipe (|).. can anyone please tell me how do i go about it?
5
6230
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I change the text in the url/location bar? ----------------------------------------------------------------------- This text can only be altered by changing the URL of the page. The normal solution is to use frames, though this can introduce problems of its own.
2
2180
by: James | last post by:
When property 'Enabled' is set to 'false', the text back ground color always turn to gray. Can I change this color? From http://developmentnow.com/g/36_2003_7_0_0_0/dotnet-languages-csharp.htm Posted via DevelopmentNow.com Groups http://www.developmentnow.com
0
1733
by: khanh | last post by:
I know how to highlight a treenode when the mouse is moving over it in a drag and drop, but what I would like to do is change the forecolor of a node and change it back when the mouse is moved away from it - sort of like when a link turns blue when you hover over it. The difficulty lies with the absent of a node mouseEnter and node mouseLeave event. Without these, there isn't a way to detect when the mouse has moved over to a different node...
6
6430
by: K Viltersten | last post by:
I have the following button: <asp:LinkButton id="Btn" runat="server" text="Click"> </asp:LinkButton> I have added an action listener in the javascript where I change the text on it: this.dom.textContent = "Clicked"; The change is effective but after the site has reloaded the text is back to "Click".
1
5515
by: Andy Sauer | last post by:
Hello. I have a database in Access 2002. I have a table where the field "Name" is set as a required field. I have a form that populates that table. When somebody forgets to fill in the Name and they attempt to proceed forward, they receive this message: "The field 'Name' cannot contain a Null value because the required property for this field is set to True. Enter a value in this field." Can I change the text of this message? I...
0
10475
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
10250
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
10222
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
10026
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
9068
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
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
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
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
3757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.