One solution for entering character control in TextBox

xiaoxiao2021-03-06  42

Private system.windows.Forms.TextBox textBox1;

PRIVATE STRING TEXT;

Public Form1 ()

{

Text = textbox1.text;

}

Private void textbox1_textchanged (Object Sender, System.Eventargs E)

{

INT LEN = text.length;

IF (len

{

INDEX = TextBox1.text.indexof (text);

CHAR C = (TextBox1.text.remove (Index, Text.length)) [0];

IF (C.Compareto ('0') <0 || C.Compareto ('9')> 0)

{

TextBox1.text = text;

TextBox1.SelectionStart = text.length;

}

}

Text = textbox1.text;

}

转载请注明原文地址:https://www.9cbs.com/read-79472.html

New Post(0)