,

C# Messagebox alt satıra geçme – Messagebox evet hayır tamam özelliği

Posted by

Merhaba bu yazımızda C# string değerlerin alt alta yazma işlemini ve Messagebox evet hayır özelliği gibi bir çok özelliğini inceliyor olacağız.

ilk olarak string değişkenlerin değerlerini alt alta yazma kodunu görelim. Lafı çok uzatmadan örneklere geçelim.

 string altalta = "Adı" + "\n" + "Soyadı";

String bir değişken tanımladık ve içerisine Adı Soyadı değerlerini alt alta yazmış bulunduk.

Şimdi birde bunu Message box içerisinde görelim.

 string altalta = "Adı" + "\n" + "Soyadı";
 MessageBox.Show(altalta);

ve Sonuç;

Şimdide MessageBox özellikleri örneklerine geçelim;

 string blog = "effectiveyazilim.com" + "\n" + "Yazılım Blog Sitesi";
 MessageBox.Show(blog, "Uyarı", MessageBoxButtons.YesNoCancel,MessageBoxIcon.Warning);
 string blog = "effectiveyazilim.com" + "\n" + "Yazılım Blog Sitesi";
 MessageBox.Show(blog, "Takip Et", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

Görüldüğü üzere başlık, simge ve butonlar değiştirilebiliyor. Peki bunu nasıl yapıyoruz diye soracak olursanız;

Sırasıyla “String değer” , “Başlık” , buton , Simge

Messagebox kutusu içerisine butonu MessageBoxButtons komutuyla yerleştirmekteyiz.
MessageBoxButtons da verilebilecek buton çeşitleri aşağıda belirtildiği gibidir;

  1. MessageBoxButtons.OK
    • Tamam butonu oluşturur.
  2. MessageBoxButtons.YesNo
    • Evet – Hayır butonları oluşturur.
  3. MessageBoxButtons.YesNoCancel
    • Evet – Hayır – İptal butonları oluşturur.
  4. MessageBoxButtons.OKCancel
    • Tamam – İptal butonları oluşturur.
  5. MessageBoxButtons.AbortRetryIgnore
    • Durdur – Yeniden Dene – Yoksay butonları oluşturur.
  6. MessageBoxButtons.RetryCancel
    • Yeniden Dene – İptal butonları oluşturur.

Messagebox kutusu içerisine simgeyi MessageBoxIcon komutuyla yerleştirmekteyiz.
MessageBoxIcon da verilebilecek simge çeşitleri aşağıda belirtildiği gibidir;

  1. MessageBoxIcon.Asterisk
  2. MessageBoxIcon.Error
  3. MessageBoxIcon.Exclamation
  4. MessageBoxIcon.Hand
  5. MessageBoxIcon.Information
  6. MessageBoxIcon.None
  7. MessageBoxIcon.Question
  8. MessageBoxIcon.Stop
  9. MessageBoxIcon.Warning
Not : Sayfa sonunda bütün simgeler mevcuttur.

Hepsini bir örnekte görmek gerekirse;

 string title = "effectiveyazilim.com - Takip Et";
 MessageBox.Show("Asterisk", title, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
 MessageBox.Show("Error", title, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
 MessageBox.Show("Exclamation", title, MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation);
 MessageBox.Show("Hand", title, MessageBoxButtons.YesNo, MessageBoxIcon.Hand);
 MessageBox.Show("Information", title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
 MessageBox.Show("None", title, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.None);
 MessageBox.Show("Question", title, MessageBoxButtons.OK, MessageBoxIcon.Question);
 MessageBox.Show("Stop", title, MessageBoxButtons.OK, MessageBoxIcon.Stop);
 MessageBox.Show("Warning", title, MessageBoxButtons.OK, MessageBoxIcon.Warning);

Sonuçlar böyle olacaktır;

Konuyu detaylı bir şekilde anlattığımızı düşünüyorum. Simgeli buton yapımını anlattığımız yazımıza Buradan ulaşabilirsiniz. Bir sonraki yazımızda görüşmek dileğiyle iyi çalışmalar.

İlginizi Çekebilir

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir