private void ultraTextEditor1_KeyUp(object sender, KeyEventArgs e)
{
UltraTextEditor te = (UltraTextEditor)sender;
var q = from _ in
new List() {
Keys.D0, Keys.D1, Keys.D2,Keys.D3, Keys.D4, Keys.D5,
Keys.D6, Keys.D7, Keys.D8,Keys.D9,
Keys.NumPad0, Keys.NumPad1, Keys.NumPad2,Keys.NumPad3, Keys.NumPad4, Keys.NumPad5,
Keys.NumPad6, Keys.NumPad7, Keys.NumPad8,Keys.NumPad9,
Keys.Delete, Keys.Decimal,Keys.Left, Keys.Right,Keys.OemPeriod,Keys.Back,Keys.Home,
}
where e.KeyCode == _
select _;
e.SuppressKeyPress = q.Count() == 0;
if ((e.KeyCode == Keys.Decimal || e.KeyCode == Keys.OemPeriod) && te.Text.Count(s => s == '.') == 1)
{
e.SuppressKeyPress = true;
}
var q1 = from _ in
new List() {
Keys.Left, Keys.Right,Keys.Back,Keys.Home,
}
where e.KeyCode == _
select _;
if (q1.Count() > 0) return;
if (te.Text.Length > 0)
{
string t = te.Text.Replace(",", "").Replace("..", ".");
double Data = Convert.ToDouble(t);
int i = (int)Math.Floor(Data);
string sInt = string.Format("{0:#,#}", i);
string dec = +t.IndexOf('.') >= 0 ? t.Substring(t.IndexOf('.')) : "";
te.Text = "";
te.AppendText(sInt + dec);
}
}
Thursday, November 4, 2010
MaskEdit Code
If no MaskEdit found do the following rough code
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment