Click here to Skip to main content
15,924,829 members
Home / Discussions / C#
   

C#

 
GeneralRe: Could not load file or assembly or one of its dependencies. The given assembly name or codebase was invalid. exception from HRESULT Pin
Marat Beiner13-Feb-11 2:01
Marat Beiner13-Feb-11 2:01 
QuestionProblem with C# code to backup sql server 2005 database Pin
M Nasir Uddin12-Feb-11 1:36
M Nasir Uddin12-Feb-11 1:36 
AnswerRe: Problem with C# code to backup sql server 2005 database Pin
Mycroft Holmes12-Feb-11 2:06
professionalMycroft Holmes12-Feb-11 2:06 
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 
Subclass Button and wrap a Timer exposing the properties and methods of it that you need.
Something like this - just set ColorA, ColorB and Interval then call Start.
C#
using System;
using System.Drawing;
using System.Windows.Forms;

public class ColoredButton : Button
{
    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);
    }
}

Dave

Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)



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 
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 

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.