Click here to Skip to main content
16,009,144 members
Home / Discussions / C#
   

C#

 
QuestionMessage Closed Pin
11-Feb-11 21:19
wenlong8811-Feb-11 21:19 
AnswerRe: Not C# question! Pin
Richard MacCutchan11-Feb-11 21:21
mveRichard MacCutchan11-Feb-11 21:21 
GeneralRe: Not C# question! Pin
OriginalGriff11-Feb-11 22:22
mveOriginalGriff11-Feb-11 22:22 
Questionhow to change the colour of buttons through timer in c# window application Pin
aeman11-Feb-11 20:22
aeman11-Feb-11 20:22 
AnswerRe: how to change the colour of buttons through timer in c# window application Pin
DaveyM6911-Feb-11 22:11
professionalDaveyM6911-Feb-11 22:11 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
aeman11-Feb-11 22:34
aeman11-Feb-11 22:34 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
DaveyM6911-Feb-11 23:04
professionalDaveyM6911-Feb-11 23:04 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
aeman12-Feb-11 0:08
aeman12-Feb-11 0:08 
I have creadted a class and when build its giving errors
Here is the code
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace ClassLibrary1
{
public class ColoredButton 
    {
        public static readonly Color DefaultColorA = Color.Red;
        public static readonly Color DefaultColorB = Color.Green;
        public const int DefaultInterval = 1000;

        public event EventHandler Tick;

        private Color colorA;
        private Color colorB;
        private Timer timer;

        public ColoredButton()
        {
            colorA = DefaultColorA;
            colorB = DefaultColorB;
            BackColor = colorA;
            timer = new Timer();
            timer.Interval = DefaultInterval;
            timer.Tick += TimerTick;
        }

        public Color ColorA
        {
            get { return colorA; }
            set { colorA = value; }
        }
        public Color ColorB
        {
            get { return colorB; }
            set { colorB = value; }
        }
        public int Interval
        {
            get
            {
                if (timer != null)
                    return timer.Interval;
                else
                    return DefaultInterval;
            }
            set
            {
                if (timer != null)
                    timer.Interval = value;
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && timer != null)
            {
                timer.Dispose();
                timer = null;
            }
            base.Dispose(disposing);
        }
        protected virtual void OnTick(EventArgs e)
        {
            EventHandler eh = Tick;
            if (eh != null)
                eh(this, e);
        }
        public void Start()
        {
            if (timer != null)
                timer.Start();
        }
        public void Stop()
        {
            if (timer != null)
                timer.Stop();
        }
        private void TimerTick(object sender, EventArgs e)
        {
            if (BackColor == colorA)
                BackColor = colorB;
            else
                BackColor = colorA;
            OnTick(EventArgs.Empty);
        }
    }
}


Errors:



Error 1 The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Documents and Settings\XPPRESP3\Local Settings\Application Data\Temporary Projects\ClassLibrary1\ColoredButton.cs 4 14 ClassLibrary1


Error 2 The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Documents and Settings\XPPRESP3\Local Settings\Application Data\Temporary Projects\ClassLibrary1\ColoredButton.cs 5 14 ClassLibrary1



Error 3 The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\XPPRESP3\Local Settings\Application Data\Temporary Projects\ClassLibrary1\ColoredButton.cs 15 32 ClassLibrary1
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
DaveyM6912-Feb-11 0:20
professionalDaveyM6912-Feb-11 0:20 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
aeman12-Feb-11 1:02
aeman12-Feb-11 1:02 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
aeman12-Feb-11 0:06
aeman12-Feb-11 0:06 
Questionhow to insert values in text box at run time in c# and assign it to int Pin
aeman11-Feb-11 19:16
aeman11-Feb-11 19:16 
AnswerRe: how to insert values in text box at run time in c# and assign it to int Pin
OriginalGriff11-Feb-11 20:23
mveOriginalGriff11-Feb-11 20:23 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
aeman11-Feb-11 21:08
aeman11-Feb-11 21:08 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
Anubhava Dimri11-Feb-11 21:19
Anubhava Dimri11-Feb-11 21:19 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
aeman11-Feb-11 21:36
aeman11-Feb-11 21:36 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
Anubhava Dimri11-Feb-11 21:44
Anubhava Dimri11-Feb-11 21:44 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
OriginalGriff11-Feb-11 21:26
mveOriginalGriff11-Feb-11 21:26 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
aeman11-Feb-11 21:33
aeman11-Feb-11 21:33 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
OriginalGriff11-Feb-11 21:45
mveOriginalGriff11-Feb-11 21:45 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
DaveyM6911-Feb-11 22:15
professionalDaveyM6911-Feb-11 22:15 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
aeman11-Feb-11 22:39
aeman11-Feb-11 22:39 
QuestionHow to Detect Music Device Pin
Pranit Kothari11-Feb-11 19:14
Pranit Kothari11-Feb-11 19:14 
QuestionSend Mail From Localhost Pin
Anubhava Dimri11-Feb-11 18:58
Anubhava Dimri11-Feb-11 18:58 
AnswerRe: Send Mail From Localhost Pin
Richard MacCutchan11-Feb-11 21:12
mveRichard MacCutchan11-Feb-11 21:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.