Butona tıklanıldığında bir saniye sonra arka plan rengini kırmızı yapan csharp kodu alternatifidir.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OrnekProje
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Timer ZamanOlcer { get; set; } = null;
public Button HedefButon { get; set; } = null;
void BirSaniyeSonraButonunArkaplanRenginiDegistir(Button button)
{
ZamanOlcer = new Timer();
ZamanOlcer.Interval = 1000;
ZamanOlcer.Enabled = true;
ZamanOlcer.Tick += new EventHandler(timer_Tick);
}
private void timer_Tick(object sender, EventArgs e)
{
HedefButon.BackColor = Color.Red;
ZamanOlcer.Stop();
}
private void button1_Click(object sender, EventArgs e)
{
HedefButon = button1;
BirSaniyeSonraButonunArkaplanRenginiDegistir(HedefButon);
}
}
}