Şekil 1 i inceleyin.
Şekil 1
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
private sayisaltxt textBox1;
public Form1()
{
InitializeComponent();
this.textBox1 = new sayisaltxt();
this.SuspendLayout();
this.textBox1.Location = new System.Drawing.Point(20, 20);
this.Controls.Add(this.textBox1);
}
public class sayisaltxt : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
{
e.Handled = true;
MessageBox.Show("Sadece rakam girebilirsiniz...", "Uyarı");
}
base.OnKeyPress(e);
}
}
}
}
Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
private sayisaltxt textBox1;
public Form1()
{
InitializeComponent();
this.textBox1 = new sayisaltxt();
this.SuspendLayout();
this.textBox1.Location = new System.Drawing.Point(20, 20);
this.Controls.Add(this.textBox1);
}
public class sayisaltxt : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
{
e.Handled = true;
MessageBox.Show("Sadece rakam girebilirsiniz...", "Uyarı");
}
base.OnKeyPress(e);
}
}
}
}
Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN
0 comments:
Yorum Gönder