Bu programda Form'un ActiveControl özelliğinden yararlanılarak textboxlara görsellik katmayı göstereceğim.Programı açtığınızda ne demek istediğimi anlayacaksınızdır.
 
Formda Bulunan Elemanlar
3 Tane Textbox
Program Kodları :
| 02 | using System.Collections.Generic; | 
 
| 03 | using System.ComponentModel; | 
 
| 08 | using System.Windows.Forms; | 
 
| 10 | namespace WindowsFormsApplication1 | 
 
| 12 |     public partial class Form1 : Form | 
 
| 16 |             InitializeComponent(); | 
 
| 19 |         private void Form1_Load(object sender, EventArgs e) | 
 
| 21 |             textBox1.ForeColor = Color.White; | 
 
| 22 |             textBox2.ForeColor = Color.White; | 
 
| 23 |             textBox3.ForeColor = Color.White; | 
 
| 24 |             Application.Idle += newEventHandler(Application_Idle); | 
 
| 28 |         private void Application_Idle(object sender, EventArgs e) | 
 
| 30 |             int sayi = this.Controls.Count; | 
 
| 31 |             for(int i = 0; i < sayi; i++) | 
 
| 33 |                 if(this.Controls[i] is TextBox) | 
 
| 35 |                     if(this.ActiveControl == this.Controls[i]) | 
 
| 36 |                         this.Controls[i].BackColor = Color.Yellow; | 
 
| 38 |                         this.Controls[i].BackColor = Color.White; | 
 
 
 
Program Ekran Çıktısı :
Share this