From others have said before me, we have to almost know what you will use this in, WinForms, ASP.NET, Silverlight ...
But now I take a chance that it is WinForm:)
private void TxtBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
e.Handled = true;
}