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ı :
| 01 | using System; | 
| 02 | using System.Collections.Generic; | 
| 03 | using System.ComponentModel; | 
| 04 | using System.Data; | 
| 05 | using System.Drawing; | 
| 06 | using System.Linq; | 
| 07 | using System.Text; | 
| 08 | using System.Windows.Forms; | 
| 09 | 
| 10 | namespace WindowsFormsApplication1 | 
| 11 | { | 
| 12 |     public partial class Form1 : Form | 
| 13 |     { | 
| 14 |         public Form1() | 
| 15 |         { | 
| 16 |             InitializeComponent(); | 
| 17 |         } | 
| 18 | 
| 19 |         private void Form1_Load(object sender, EventArgs e) | 
| 20 |         { | 
| 21 |             textBox1.ForeColor = Color.White; | 
| 22 |             textBox2.ForeColor = Color.White; | 
| 23 |             textBox3.ForeColor = Color.White; | 
| 24 |             Application.Idle += newEventHandler(Application_Idle); | 
| 25 | 
| 26 |         } | 
| 27 | 
| 28 |         private void Application_Idle(object sender, EventArgs e) | 
| 29 |         { | 
| 30 |             int sayi = this.Controls.Count; | 
| 31 |             for(int i = 0; i < sayi; i++) | 
| 32 |             { | 
| 33 |                 if(this.Controls[i] is TextBox) | 
| 34 |                 { | 
| 35 |                     if(this.ActiveControl == this.Controls[i]) | 
| 36 |                         this.Controls[i].BackColor = Color.Yellow; | 
| 37 |                     else | 
| 38 |                         this.Controls[i].BackColor = Color.White; | 
| 39 |                 } | 
| 40 |             } | 
| 41 |         } | 
| 42 | 
| 43 |     } | 
| 44 | } | 
Program Ekran Çıktısı :
 



