You are on page 1of 16

1

Bölüm

FORM 2
Form'un özellikleri aşağıda özetlenmektedir.

1. AcceptButton

Kontrol çalışırken ENTER tuşuna basıldığında, hangi butonun “tıklama” olayının aktifleştirileceğini;
yani hangi butona tıklanılmış gibi davranılacağını belirtir.

Ornek1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
MessageBox.Show("ENTER (dolaylı olarak Tamam) tuşuna
bastınız");
}
}
}

2. AccesibleDescription

Nesneyi (kontrolü) tanımlayan (açıklayan) ifadedir.

3. AccesibleName

Açıklamayı (erişimi) gösteren nesne ismidir.

4. AccesibleRole

Nesnenin hangi görevde kullanılacağını belirtir.

5. AllowDrop

Sürükle-bırak olayları ile nesnenin veri kabul edip etmeyeceğini belirtir.

6. AutoScaleMode

Otomatik ölçeklendirme modunu ayarlar. Tablo 1’deki değerleri alabilir.

Prof. Dr. Fahri VATANSEVER


2

Tablo 1. AutoScaleMode değerleri


Değer Açıklama
None Otomatik ölçeklendirme yapılmıyor (kapalı)
Font Nesneler kullanılan yazı tipine (genellikle de sistem yazı tiplerine) göre ölçeklenir.
Dpi Nesneler ekran çözünürlüğüne göre ölçeklenir.
Inherit Çoklu form uygulamalarında kontroller, ebeveynin moduna göre ölçeklenir. Eğer ebeveyn yoksa otomatik ölçekleme devre dışı
kalır.

6. AutoScroll

Kontrol, form üzerine sığmadığında kaydırma çubuklarının otomatik olarak eklenip eklenmeyeceğini
belirtir.

7. AutoScrollMargin

Otomatik kaydırma kenar boşluklarını genişlik ve yükseklik olarak ayarlar.

8. AutoScrollMinSize

Otomatik kaydırma çubuğunun genişlik ve yükseklik olarak en küçük boyutlarını ayarlar.

9. AutoSize

“AutoSizeMode” özelliğindeki değere göre kontrolün otomatik yeniden boyutlandırılmasını sağlar.

10. AutoSizeMode

Kontrolün otomatik yeniden boyutlandırılmasını şeklini belirler ve Tablo 2’deki değerleri alabilir.

Tablo 2. AutoScaleMode değerleri


Değer Açıklama
GrowAndShrink Kontrol içeriğine göre büyür/küçülür. Elle büyütüp/küçültme yapılamaz.
GrowOnly Kontrol, içeriğine göre büyür ancak “Size” özelliğindeki değerden daha küçülemez.

11. AutoValidate

Kontroller arasındaki aktiflik geçişlerinde doğrulama amaçlı bir değer ataması yapar ve Tablo 3’teki
değerleri alabilir.

Tablo 3. AutoScaleMode değerleri


Değer Açıklama
Disable Etkin değil.
EnablePreventFocusChange Kontrol aktifliğini (odağı) kaybettiğinde oluşur.
EnableAllowFocusChange Doğrulama gerçekleşir, ancak hata olması durumunda yine de kontrolün aktifliği değişir. Doğrulama
başarısız olursa “Valitade” olayı gerçekleşmez.
Inherit Diğer kontrolün “AutoValidate” değerini alır.

12. BackColor

Kontrolün zemin rengini belirtir.

Kullanım şekilleri:

kontrol.BackColor = System.Drawing.Color.renk;
kontrol.BackColor = System.Drawing.SystemColors.renk;
kontrol.BackColor = SystemColors.renk;

Prof. Dr. Fahri VATANSEVER


3

Ornek2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ornek2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_KeyDown(object sender, KeyEventArgs e)


{
this.BackColor = System.Drawing.Color.Red;
}

private void Form1_KeyUp(object sender, KeyEventArgs e)


{
this.BackColor = System.Drawing.Color.Yellow;
}
}
}

13. BackgroundImage

Kontrolün arka plan resmini belirtir.

14. BackgroundImageLayout

Kontrolün arka plan resminin yerleşimini belirtir.

15. CancelButton

Klavyedeki ESC tuşuyla ilgili buton kontrolünü bağlar. Yani klavyeden ESC tuşuna basıldığında, ilgili
butonda Click olayı meydana gelir.

Ornek3
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ornek
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
this.Text = "ESC tuşuna bastınız, dolayısıyla ESC butonunda
Clik olayı meydana geldi";
}
}
}

Prof. Dr. Fahri VATANSEVER


4

16. CausesValidation

Kontrol için doğrulama değeri gerekip gerekmeyeceğini belirler.

17. ContextMenuStrip

Kontrol üzerinde sağ tıklandığında açılacak olan alt menüye kısayol ayarlar.

18. ControlBox

Kontrolün Control veya System menu kutusu olup olmayacağını belirtir.

Ornek4
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public void sekil()


{
this.FormBorderStyle = FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.ControlBox = false;
}

private void button1_Click(object sender, EventArgs e)


{
sekil();
}
}
}

19. Cursor

İmlecin kontrol üzerine geldiğinde alacağı şekli belirtir.

20. DoubleBuffered

Kontrolün ikinci bir arabellek kullanıp kullanmayacağını belirtir.

21. Enabled

Kontrolün etkin olup olmayacağını belirtir.

22. Font

Kontrolün yazı biçimini (fontunu) belirtir.

kontrol.Font = new Font(yazı tipi ismi, büyüklük, FontStyle.biçim);

Prof. Dr. Fahri VATANSEVER


5

Ornek5
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void radioButton1_CheckedChanged(object sender, EventArgs e)


{
if (radioButton1.Checked) label1.Font= new Font("Arial", 36,FontStyle.Bold);
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)


{
if (radioButton2.Checked) label1.Font = new Font("Times New Roman", 36,
FontStyle.Italic);
}
}
}

23. ForeColor

Kontrolün yazı rengini belirtir.

24. FormBorderStyle

Formun kenarlık biçimini belirtir.

25. HelpButton

Yardım butonunun olup olmayacağını belirtir. Tam ekran (MaximizeBox) ve simge durumu
(MinimizeBox) butonlarının bulunması halinde “yardım” butonu aktifleşmemektedir.

26. Icon

Formun ikonunu belirtir.

27. ImeMode

Kontrolün Input Method Editor (IME) modunu belirtir. Yani farklı karakter tiplerinde girişlerin yapılıp
yapılamayacağını belirtir.

28. IsMdiContainer

Formun çoklu belge arabirimi (Multiple Document Interface – MDI) uygulamaları için bir alt form
olup olmadığını belirtir.

Prof. Dr. Fahri VATANSEVER


6

29. KeyPreview

Klavyedeki tuş olaylarında önceliğin formda ya da üzerindeki formda olup olmadığını ayarlar. False
ise öncelik kontrolde, True ise Form’dadır.

Ornek6
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_KeyDown(object sender, KeyEventArgs e)


{
this.Text = "Tuş önceliği: Form";
}

private void textBox1_KeyDown(object sender, KeyEventArgs e)


{
textBox1.Text = "Tuş önceliği: TextBox";
}
}
}

30. Language

İlgili dili belirtir.

31. Localizable

Uygulamanın yerleştirilip yerelleştirilmeyeceğini (dil vs.) belirtir.

32. Location

Kontrolün sol üst köşeye göre göreceli konumunu belirtir.

Ornek7
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ornek7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int x = 0, y = 0;
private void Form1_Click(object sender, EventArgs e)
{

Prof. Dr. Fahri VATANSEVER


7

x+=10; y+=10;
button1.Location = new Point(x, y);
}
}
}

33. Locked

Kontrolün kilitli olup olmayacağını, yani konumunun değiştirilip değiştirilemeyeceğini belirtir.


(Formun üzerine bir tane buton yerleştirerek göster)

34. MainMenuStrip

Kontrolün ana menüsünü ilişkilendirir.

35. MaximizeBox

“Tam ekran” ikonunun etkin olup olmayacağını belirtir.

36. MaximumSize

Formun maksimum olabileceği boyutlarını belirtir.

37. MinimizeBox

“Simge durumuna küçültme” ikonunun etkin olup olmayacağını belirtir.

38. MinimumSize

Formun minimum olabileceği boyutlarını belirtir.

39. Opacity

Formun şeffaflığını ayarlar.

Ornek8
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_ResizeEnd(object sender, EventArgs e)


{
this.Opacity -=.1;
}
}
}

Prof. Dr. Fahri VATANSEVER


8

40. Padding

Kontrolün içsel kenar boşluklarını belirtir.

41. RightToLeft

Kontrolün soldan sağa türü hizalamada olup olmayacağını belirtir.

42. RightToLeftLayout

Soldan sağa yansımanın aktif olup olmadığını belirtir.

43. ShowIcon

Form ikonunun olup olmayacağını belirtir.

44. ShowInTaskbar

Uygulamanın görev çubuğunda gösterilip gösterilmeyeceğini belirtir.

45. Size

Kontrolün genişlik ve yükseklik olarak boyutlarını belirtir.

46. SizeGripStyle

Boyutlandırma ızgarasının Formun sağ alt köşesinde görünüp görünmeyeceğini belirtir.

47. StartPosition

Uygulamanın ekrandaki başlangıç konumunu belirtir.

48. Tag

İlgili kontrol hakkındaki kullanıcı tanımlı etiketi belirtir.

49. Text

Form başlığındaki metni belirtir.

Prof. Dr. Fahri VATANSEVER


9

50. TopMost

Formun daima en üste kalacak form olup olmayacağını belirtir.

50. TransparencyKey

Formun saydam alanlarını temsil edecek rengi ayarlar. (Formun saydam rengini kırmızıya ayarlayıp
üzerine kırmızı buton yerleştir)

51. UseWaitCursor

Kontrol üzerinde imlecin “bekleyin” şeklini alıp almayacağını belirtir.

52. WindowState

Uygulama penceresinin başlangıç durumu (tam ekran, simge durumuna küçültülmüş veya normal)
belirtir.

Form'a ait olaylar aşağıda özetlenmektedir:

1. Activated

Kontrol aktif hale geldiğinde meydana gelir.

2. AutoSizeChanged

Kontrolün “AutoSize” özelliği değiştiğinde meydana gelir.

3. AutoValidateChanged

Kontrolün “AutoValidate” özelliği değiştiğinde meydana gelir.

4. BackColorChanged

Kontrolün “BackColor” özelliği değiştiğinde meydana gelir.

Ornek9
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ornek9
{ public partial class Form1 : Form
{
public Form1()
{ InitializeComponent(); }
int s = 0;
private void button1_Click(object sender, EventArgs e)
{
this.BackColor = System.Drawing.Color.Blue;
}
private void Form1_BackColorChanged(object sender, EventArgs e)
{
s++;
this.Text = "Zemin rengini " + Convert.ToString(s) + "

Prof. Dr. Fahri VATANSEVER


10

değiştirdiniz.";
}
private void button2_Click(object sender, EventArgs e)
{
this.BackColor = System.Drawing.Color.Green;
}
}
}

5. BackgroundImageChanged

Kontrolün “BackgroundImage” özelliği değiştiğinde meydana gelir.

6. BackgroundImageLayoutChanged

Kontrolün “BackgroundImageLayout” özelliği değiştiğinde meydana gelir.

7. BindingContextChanged

Kontrolün “BindingContext” özelliği değiştiğinde meydana gelir.

8. CausesValidationChanged

Kontrolün “CausesValidation” özelliği değiştiğinde meydana gelir.

9. ChangeUICues

Odaklama veya klavye kullanıcı arabirimi değişimi değiştiğinde meydana gelir.

10. Click

Kontrole tıklandığında (tek tıklama) meydana gelir.

Ornek10
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ornek10
{
public partial class Form1 : Form
{
public Form1()
{ InitializeComponent(); }

private void Form1_Click(object sender, EventArgs e)


{ this.Hide();
Form2 f2= new Form2();
f2.Show();
} }}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ornek10
{
public partial class Form2 : Form

Prof. Dr. Fahri VATANSEVER


11

{
public Form2()
{ InitializeComponent(); }

private void Form2_Click(object sender, EventArgs e)


{
this.Hide();
Form1 f1 = new Form1();
f1.Show();
} }}

Ornek11
using System;
Form1: using System.Collections.Generic;
IsMdiContainer:True using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ornek6
{
public partial class Form1 : Form
{ public Form1()
{ InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e)


{
Form2 altform = new Form2();
altform.MdiParent = this;
altform.Show();
} } }

11. ClientSizeChanged

Kontrolün “ClientSize” özelliği değiştiğinde meydana gelir.

12. ContextMenuStripChanged

Kontrolün “ContextMenuStrip” özelliği değiştiğinde meydana gelir.

13. ControlAdded

Yeni kontrol eklendiğinde meydana gelir.

14. ControlRemoved

Kontrol kaldırıldığında meydana gelir.

15. CursorChanged

Kontrolün “Cursor” özelliği değiştiğinde meydana gelir.

16. Deactivated

Kontrol pasif duruma geçtiğinde meydana gelir.

17. DockChanged

Kontrolün “Dock” özelliği değiştiğinde meydana gelir.

Prof. Dr. Fahri VATANSEVER


12

18. DoubleClick

Fare ile çift tıklama gerçekleştiğinde meydana gelir.

19. DragDrop

Sürükle-bırak olayı tamamlandığında meydana gelir.

20. DragEnter

Nesne sürüklenirken başka bir kontrolün sınırlarına girdiğinde meydana gelir.

21. DragLeave

Nesne sürüklenirken başka bir kontrolün sınırlarından çıktığında meydana gelir.

22. DragOver

Kontrol, başka bir kontrolün sınırları üzerinde sürüklenirken meydana gelir.

23. EnabledChanged

Kontrolün “yetkilendirme” durumu değiştiğinde meydana gelir.

24. Enter

Form üzerinde kontrolün aktifleşmesi durumunda meydana gelir.


Ornek12
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void textBox1_Enter(object sender, EventArgs e)


{
textBox2.Clear();
textBox1.Text = "Burası aktif";
}

private void textBox2_Enter(object sender, EventArgs e)


{
textBox1.Clear();
textBox2.Text = "Burası aktif";
}
}
}

25. FontChanged

Kontrolün “Font” özelliği değiştirildiğinde meydana gelir.

Prof. Dr. Fahri VATANSEVER


13

26. ForeColorChanged

Kontrolün “ForeColor” özelliği değiştirildiğinde meydana gelir.

27. FormClosed

Form kapatıldığında/kapandığında meydana gelir.

28. FormClosing

Form kapatılırken meydana gelir.

Ornek13
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek12
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)


{
MessageBox.Show("Programınız kapanacak");
}
}
}

29. GiveFeedback

Sürükleme işlemi boyunca meydana gelir.

30. HelpButtonClicked

Yardım butonuna tıklandığında meydana gelir.

Ornek14
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek13
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

Prof. Dr. Fahri VATANSEVER


14

private void Form1_HelpButtonClicked(object sender, CancelEventArgs e)


{
MessageBox.Show("Yardım butonuna tıkladınız");
}
}
}

31. HelpRequested

Kullanıcı tarafından kontrol için yardım çağırıldığında meydana gelir.

32. ImeModeChanged

Kontrolün “ImeMode” özelliği değiştiğinde meydana gelir.

33. InputLanguageChanged

Kontrolün “InputLanguage” özelliği değiştiğinde meydana gelir.

34. InputLanguageChanging

Sistem tarafından kontrolün “InputLanguage” özelliği değişimi için istek gönderildiğinde meydana
gelir.

35. KeyDown

Klavyeden tuşa ilk basıldığı anda meydana gelir.

35. KeyPress

Klavyeden tuşa ilk basılma anından bırakılıncaya kadar ve kontrol aktif olduğu sürece meydana gelir.

36. KeyUp

Klavyeden basılan tuş bırakıldığında meydana gelir.

Ornek15
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek14
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

int s=0;

private void Form1_KeyPress(object sender, KeyPressEventArgs e)


{
s++;
this.Text = Convert.ToString(s);
}
}

Prof. Dr. Fahri VATANSEVER


15

Klavyedeki tuş olayları “KeyEventArgs” değerlerini de verir (Tablo 1).

Özellik Açıklama
Alt “Alt” tuşuna basılı olup olmadığını
Control “Ctrl” tuşuna basılı olup olmadığını
Handled
KeyCode Klavye kodunu verir (Keys.karakter)
KeyData Klavye tuş verisi
KeyValue “KeyData”nın tamsayı gösterimi
Modifiers Ctrl, Shift vb. kombinasyonları
Shift “Shift” tuşuna basılı olup olmadığını

Ornek16
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek15
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyValue==65) this.BackColor=System.Drawing.Color.Red;
else if (e.KeyCode==Keys.B) this.BackColor=System.Drawing.Color.Blue;
else if ((e.Shift) && (e.KeyCode==Keys.C)) this.BackColor =
System.Drawing.Color.Green;
else this.BackColor=System.Drawing.Color.White;
}
}
}

Ornek17
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek16
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyCode == Keys.PageUp)
{ this.Width += 10; this.Height += 10; }
if (e.KeyCode == Keys.PageDown)
{ this.Width -= 10; this.Height -= 10; }

Prof. Dr. Fahri VATANSEVER


16

}
}
}

Ornek18
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ornek17
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyCode == Keys.Down) this.Top += 10;
if (e.KeyCode == Keys.Up) this.Top -= 10;
if (e.KeyCode == Keys.Right) this.Left += 10;
if (e.KeyCode == Keys.Left) this.Left -= 10;
}
}
}

Prof. Dr. Fahri VATANSEVER

You might also like