473,749 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change color of form after every 3 sec. in vc#

4 New Member
i want to change color of form after every 3 sec. in vc#. How it can be done with the help of timer. Do i need to use a loop if yes then how?

Thanx
Sep 15 '10 #1
9 2213
Frinavale
9,735 Recognized Expert Moderator Expert
Add a Timer control to the form and implement code that handles time Timer's Tick event. In that method set the Window.Form.Bac kColor property.

-Frinny
Sep 15 '10 #2
information99
4 New Member
I have already tried this but can u suggest me something else my code is
Expand|Select|Wrap|Line Numbers
  1.  private void timer1_Tick(object sender, EventArgs e)
  2.  {
  3.    this.BackColor = Color.Red;
  4.  }
Plz. help me out

Thankx
Sep 15 '10 #3
Frinavale
9,735 Recognized Expert Moderator Expert
Try calling the Update method afterwords to force the control to refresh.
Sep 15 '10 #4
Plater
7,872 Recognized Expert Expert
That code always sets the background to red. Then what?
Sep 15 '10 #5
Subin Ninan
91 New Member
Use an IF...ELSE condition in timer_tick event to set different colors depending upon value property of timer control.
Sep 16 '10 #6
information99
4 New Member
hi
thankx for ur suggestions. Somebody suggested me to use random class/method. but i dont know how to use here. plz. guide.
Sep 18 '10 #7
Subin Ninan
91 New Member
you can use random class as:

Expand|Select|Wrap|Line Numbers
  1. Random rndObj = new Random();           
  2. if(rndObj.Next(1, 4).ToString()== "1")
  3. {
  4. this.BackColor = Color.Red;
  5. }
  6. else
  7. if(rndObj.Next(1, 4).ToString()== "2")
  8. {
  9. this.BackColor = Color.Green;
  10. }
  11. else
  12. if(rndObj.Next(1, 4).ToString()== "3")
  13. {
  14. this.BackColor = Color.Yellow;
  15. }
  16. else
  17. {
  18. this.BackColor = Color.White;
  19. }
Sep 19 '10 #8
information99
4 New Member
Thanks, but i want to change the color with timer.
Sep 20 '10 #9
alzcuty
1 New Member
just put a timer on the form and set its interval to 1000 that is, representing milliseconds... .

play Button:
Expand|Select|Wrap|Line Numbers
  1. Timer1.start();
Now on ur .cs file...

Expand|Select|Wrap|Line Numbers
  1. public int a=10; 
then on the timer's tick event.put the following code
Expand|Select|Wrap|Line Numbers
  1. a--;
  2. if(a==10)
  3.   this.backcolor= color.red;
  4.  
  5. else if(a==9)
  6.   this.backcolor= color.blue;
and so on....
Oct 5 '11 #10

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

Similar topics

2
2574
by: vikas2923 | last post by:
Can any body tell me plz how to change color on deactivating a text box i had tried the code but every time it is giving an error message "object not defined" .Pleased provide me the cod of it or kindly give suject a logic for it Vikas Thanks in advance
2
13145
by: nitindutt2005 | last post by:
Hi I have a html file as below. ==================================================================== <html> <head> <td style="background-color:rgb(170, 157, 244);"> <table border="0" cellpadding="5" cellspacing="2" width="95%">
1
2475
by: itsenthil | last post by:
This is my Usercontrolcoding. what is wrong in this coding plz help me <script type="text/javascript" language="javascript"> function output() { var cb =document.getElementById("cbtest"); if(cb.checked == true)
2
2482
by: ksingh | last post by:
I have a form with a sub form and I want the field on the main form to change color if the date is greater than today. The field on the main form changes when I scroll from one record to another. I tried the following code but I get an error that the field is not recognizable. Private Sub Form_Current() If Me!TargetFundingdate < Date Then Me!TargetFundingdate.BackColor = 255 Else Me!TargetFundingdate = vbWhite End If
1
2401
by: dotcom | last post by:
hello friends, in my form my div has both scrolling (horizontal as well as vertical) but for horizontal scrollbar i want to change color plz help me if anybody know the solution
5
3157
by: abhubbart | last post by:
I want change the color on the font to red for the text within the div element. I have the following code. <style type="text/css"> .style2 {color: #000000} </style>
2
4840
by: cloh | last post by:
Hi all, Does anyone know if it is possible to change the color of a radio button in a form? Changing either the color of the border or the dot would work for me - I just need it to stand out from the background of the form and I would rather not change the form color. Thanks in advance!
10
3911
by: The Bicycling Guitarist | last post by:
Hello. I have a navigation bar at the top of all my pages with css-styled buttons that change color when hovered over. I am a little confused on how to disable that for the link that the page is on, for example, the sitemap link in the navigation bar on the sitemap page, the studies link for the navigation bar on the studies page, etc. The css is at http://www.TheBicyclingGuitarist.net/css/style.css The sitemap is at...
3
2781
by: viki1967 | last post by:
Hi all. This code javascript not working... nothing error but not working... :( I need change color in the fields of the form when fields is null... My code:
1
1343
by: Anwesha | last post by:
Hi, i have a problem while working with .net 2005. i have a situation where i have to change the form id which takes 'form1' by default. it donot allow me to change the id form the property window. is there any procedure to change the id of the form....plz help...
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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
9254
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
8255
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...
1
6799
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
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
4608
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
3319
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
2791
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.