mandag 11. mai 2009

only allow text in textbox

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;
using System.Text.RegularExpressions;

namespace numbox_test
{


public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Regex FormatControl = new Regex(@"\D");
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (FormatControl.IsMatch(textBox1.Text))
{
textBox1.Text = "";
MessageBox.Show("Only numeric format would be accepted");
}

}

Ingen kommentarer:

Legg inn en kommentar