• Forumzar.COM Türkçe içerikli genel forum sitesi ve paylaşım platformu olarak eğlenceli ve interaktif bir forum deneyim sunar.

    Foruma üye olmak için BURAYA TIKLAYINIZ

KeyPress ve Error Provider Kullanımı

miRBey

Forum Üyesi
Katılım
5 Eki 2022
Mesajlar
180
Puanları
16
Kod:
Kod:
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 KeyPress
{
public partial class Form1 : Form
{
DateTime dogumTarih = new DateTime();
string ad = "";
string soyad = "";
string tcNo = "";

public Form1()
{
InitializeComponent();
}

private **** btnFormuAc_Click(object sender, EventArgs e)
{
formerrorprovider f = new formerrorprovider();
f.BunuAcanform = this;
f.Show();
this.Hide();
}

private **** btnKaydet_Click(object sender, EventArgs e)
{
ad = txtAd.Text;
soyad = txtSoyad.Text;
dogumTarih = DateTime.Parse(txtDtarih.Text);
tcNo = txtTCNO.Text;
}

private **** txtAd_KeyPress(object sender, KeyPressEventArgs e)
{

if (char.IsNumber(e.KeyChar) && e.KeyChar != '\b')
{
e.Handled = true;
}
}

private **** txtSoyad_KeyPress(object sender, KeyPressEventArgs e)
{
if (char.IsNumber(e.KeyChar) && e.KeyChar != '\b')
{
e.Handled = true;
}
}

private **** txtDtarih_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsNumber(e.KeyChar) && e.KeyChar != '.' && e.KeyChar != '\b')
e.Handled = true;
}

private **** txtTCNO_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsNumber(e.KeyChar) && e.KeyChar != '\b')
e.Handled = true;
}
}
}







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 KeyPress
{
public partial class formerrorprovider : Form
{
public formerrorprovider()
{
InitializeComponent();
}

public Form1 BunuAcanform = null;

private **** txtkod_Validating(object sender, CancelEventArgs e)
{
if (string.IsNullOrEmpty(txtkod.Text) || txtkod.Text.Trim().Equals(""))
return;
if (!char.IsLetter(txtkod.Text[0]) || txtkod.Text.Length != 5)
{
errorProvider1.SetError(txtkod, "Firma kodu 5 karakterden oluşmalı ve ilk karakter harf olmalı");
e.Cancel=true;
}
else
errorProvider1.Clear();
}

private **** btnKaydetIlerle_Click(object sender, EventArgs e)
{
MessageBox.Show("Diger bölümü hazır olmadıgından ilerleyemeyeceksiniz...");
}


private **** frmerrorprovider_FormClosed(object sender, FormClosedEventArgs e)
{
BunuAcanform.Show();
}
}
}
 

Genel Forum Sitesi

Forum Sitesi - Forumzar.COM

Forumzar.COM olarak, Türkçe forum sitesi denildiğinde akla gelen ilk adres olarak, geniş kapsamlı genel forum platformumuzda buluşuyoruz. Türkiye'nin en büyük Türkçe forum siteleri arasında yer almanın gururunu yaşıyoruz. Çeşitli konu başlıklarında aktif bir şekilde paylaşımların yapıldığı, her konuda interaktif ve bilgilendirici tartışmalara katılmak için bizi takip edin! ve bir dakikanızı ayırarak forum sitemize üye olun!

Forum Siteleri

Bilgi paylaştıkça çoğalır sloganı ile ilerleyen forum sitesi platformumuza, siz de üye olarak forum sitemizde açılan konulara katılabilir ve ilgi alanınıza uygun konular açarak siz de paylaşımda bulunabilirsiniz.