Does anybody know how to show a text for a particular time in a label or in a textbox? Suppose if I clicked a button it show the text typed in the textbox in a label for 15 seconds and then it should disappear.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Use the Timer component which allows you to specify a recurring interval at which the
Elapsed
event is raised in your application. You can then handle this event to provide regular processing.The Timer.Interval Property is used to set the interval at which to raise the Elapsed event.
If Enabled is set to true and AutoReset is set to false, the
Timer
raises theElapsed
event only once, the first time the interval elapses.The
Timer
component raises the Elapsed event, based on the value of the Interval property. You can handle this event to perform the processing you need.Use the Timer.Start Method to start raising the
Elapsed
event by settingEnabled
to true.Use the Timer.Stop Method to stop raising the
Elapsed
event by settingEnabled
to false.Refer to the following sample.
Timer Class.
Code Example
Referance
Assuming a web page:
You can do this through
javascript
, you don't want to do this in C# as that's handled server side.Assuming a windows app:
You could use a
timer
to remove the label after a few seconds.Try specifying what type of application you're working on in the question as it makes it easier to give a concise answer.
I'm going to take a wild guess like everyone else... if this solution is not useful at this time then it maybe useful for others searching on this subject.
If you are using WPF it is trivial, check this complete sample which fades the textbox out over 5 seconds once it has lost focus. The second textbox is there simply to give you something to move focus to :)
you can use timer class.
Show the text and the elapsed event of timer hide the text. Check the link
You can use a timer. You don't say if this is WinForms or WPF, so I'll assume WPF, but you can use a
System.Windows.Timers.Timer
just as well.