C# Active Control Kullanımı


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

01using System;
02using System.Collections.Generic;
03using System.ComponentModel;
04using System.Data;
05using System.Drawing;
06using System.Linq;
07using System.Text;
08using System.Windows.Forms;
09
10namespace 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 += new EventHandler(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ı :


Share this

Related Posts

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer