private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
{
e.Handled = true; // Girilen karakter sayı değilse
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text) || !textBox1.Text.All(char.IsDigit))
{
textBox1.Text = "0"; // TextBox boşsa veya içeriğinde harf varsa 0 değerini yazar.
}
}