Dialog Kutusu Düğmeleri[C#]

28 Mart 2010 – 09:55 Bu örnek ile programlarınızı kapatırken kullanıcıya çıkmak istediğinden eminmisin tarzında ekranlar çıkarabilirsiniz.Görsellik açısından güzel bir örnek.
![dialogkutusu dialogkutusu Dialog Kutusu Düğmeleri[C#]](http://www.csharptr.com/wp-content/uploads/2010/03/dialogkutusu.jpg)
Kodlar
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace DialogKutusuDüğmeleri { public class Form1 : System.Windows.Forms.Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, System.EventArgs e) { textBox1.Text=""; //Bilgi.dat dosyasındaki satırları textBox1 içine al try { System.IO.TextReader dosya = System.IO.File.OpenText("bilgi.dat"); string satır; while((satır = dosya.ReadLine())!= null) textBox1.Text+=satır+(char)13+(char)10; dosya.Close(); } catch { ; } } private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Form2 f = new Form2(); DialogResult c; f.Text = "Çıkış"; c = f.ShowDialog(); switch(c) { case DialogResult.Yes: //Evet seçildiyse //textBox1 içindeki bilgileri bilgi.dat içine yaz System.IO.TextWriter dosya=System.IO.File.CreateText("bilgi.dat"); dosya.Write(textBox1.Text); dosya.Close(); break; case DialogResult.No: //Hayır seçildiyse bir iş yapmaya gerek yok break; case DialogResult.Cancel: //İptal seçildiyse e.Cancel = true; //çıkışı iptal et break; } } private void button1_Click(object sender, System.EventArgs e) { Form2 f =new Form2(); DialogResult c; f.Text = "Sil"; f.label1.Text = "D İ K K A T !!!\r\n" + "Text kutusunun içeriği silinsin mi?"; f.button3.Visible = false; c = f.ShowDialog(); //Evet seçildiyse sil if (c == DialogResult.Yes) textBox1.Text = ""; } } } |
Not:Program VS2005 ile derlenmiştir.
Linkler
RapidShare
SendSpace
Csharptr
Etiketler: ”C#, dialog kutusu”