Imran Pervez

Imran Pervez

  • NA
  • 45
  • 0

TextBox Custom Control

Sep 13 2010 4:49 AM

I designe a texbox Custom control for decimal number it built successfully but when i use it in my application this control not show text box property in property windows show only custom control property (how i inherit or bind my costum control with single textbox and its property) i want to use my custom control textbox TEXT property in my application
my code is (for text fox in custom control)
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Drawing;
using
System.Data;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
namespace
DecimalTextBox
{

public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text == "")
textBox1.Text =
"0.0";
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsDigit(e.KeyChar))
e.Handled =
true;
if (e.KeyChar == 8)
e.Handled =
false;
if (e.KeyChar == 13)
SendKeys.Send("{TAB}");
 
 
string check4dot = ".";
string searchstring = textBox1.Text;
int checkit = searchstring.IndexOf(check4dot);
if (checkit > 1)
{
if (e.KeyChar == 46)
e.Handled =
true;
}
else
{
if (e.KeyChar == 46)
e.Handled =
false;
}
}
}
}

Attachment: DecimalTextBox.rar

Answers (3)