473,398 Members | 2,335 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,398 software developers and data experts.

handle forms using timers

4
i need to run a form in the background(Main),on top of that another form(Main1) runs.
when Main1 loads it should wait for 10 seconds and direct to another form(bpaper) if the system time is less than 4.00 p.m
if the system time is greater than 4.00 p.m then it should remain in the Main1
how can i do this using a timer?
(Main forms' isMdiContainer is true!)


form load of Main
Expand|Select|Wrap|Line Numbers
  1. Main1 one = new Main1();
  2. one.MdiParent = Main.ActiveForm;
  3. one.Show();
  4.  


form load of Main1
Expand|Select|Wrap|Line Numbers
  1. timer1.Start();
  2. timer1.wait(1000);  //how can i wait the timer here?
  3.  
  4. t1 = DateTime.Now;            
  5. t2 = Convert.ToDateTime("16:00:00 ");
  6. bpaper test = new bpaper();
  7.  
  8.  
  9. //do not allow the bpaper to be appear after 4oclock
  10. if (t1<t2)  
  11.        {            
  12.         timer1.Stop();
  13.         this.Hide();
  14.         test.Show();
  15.         }
  16. else
  17.         {
  18.            timer1.Stop();
  19.            this.Show();               
  20.            MessageBox.Show("Time out ",t1.ToString());
  21.         }
  22.  
  23.  
  24.  
Oct 3 '11 #1
3 1921
GaryTexmo
1,501 Expert 1GB
Looking at your code, why do you need the timer to wait? Just set the interval to whatever tick rate you want and the Tick event will occur on that interval. Other than that, the general idea of your code looks fine. In the Tick event, check the time and take the appropriate action.

My apologies if I'm not understanding your problem correctly. If this is the case, can you please be more descriptive?
Oct 3 '11 #2
kayo
4
i need to run the timer for 10seconds.within that time it should check the t1 and t2 values.
if t1<t2 ---->current form(Main1) should hide.
otherwise remain in the same form(Main1)
can u please help me to construct the code for this purpose.


should i set interval to 10sec?
how to occur the tick event in the interval?
tick event must have the t1 N t2 comparisons and relevant form actions
Oct 4 '11 #3
GaryTexmo
1,501 Expert 1GB
Read up on the Timer class. That page contains all the properties and methods you can access, as well as an example at the bottom.

So yes, you can set your interval to 10 seconds. The interval is actually in milliseconds, so you would set it to 10000. Then put your comparison code in the Elapsed method. This used to be called Tick, so you might be able to use that too but it doesn't matter, they mean the same thing.

Inside that event, you can do your comparison, then take the appropriate actions. Give the coding a try and if you have troubles, post back here and I'll try to help you through it.
Oct 4 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Alireza Haghshenass | last post by:
Dear All, I am facing a problem which I could not solve. I am writing an application which uses a notify icon and a context menu bound to it to show modal dialog forms. When these forms is shown...
2
by: juventusaurabh | last post by:
Hello, Can anyone please give me any referencese or links related to database handling in windows forms using C#.Net.
2
by: Visu | last post by:
Hi All, I am new to this group, and I would like to know how we can design a windows application which would automatically change the form size, controls size, position etc., as and when the...
1
by: surgesm | last post by:
I've been trying to create a textbox that will eventually create a calculator. I'm trying to get it to ignore characters. I'm not sure where to put this function to get it to work. I currently have...
11
by: mauiboy | last post by:
programming newbie. I'm work on a program that post characters into foreground application. everything is working nicely except for repeating characters. I thought using a task timer was the way to...
2
by: nandapoy | last post by:
Hi if i use me.findcontrols in vb.net 2005, it shows error. Help me to clear textboxes in all forms using function
2
by: sliperdm | last post by:
helo there?] im quite new to Visual Basic and C++.. how to use a timers in a visual basic applications?
0
by: moyoal | last post by:
Dear All, this is my first experience to connect forms and database using VPN / DSL from other location. we have client/server architectures, .FMX are available in 212.147.1.63 server. ...
6
by: =?Utf-8?B?Unlhbg==?= | last post by:
I am trying to pass a value from a texbox in Form1 to a textbox in Form2 using properties in VS2005 but it doesn't work; please help (project is attached). Code for Game Class: using System;...
0
by: btreddy | last post by:
Hiii.., I want to implement a concept in Windows Forms using C# which is very similar to Master Pages in ASP.NET . Like you know i've a Master Form which is having a toolbar knd of control...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.