目前,我正在使用方法突出显示TextBox中的文本,但它只是有时起作用。
此代码必须验证输入的文本中是否包含空格。如果文本中有空格,则应该警告用户,然后必须突出显示TextBox中的文本:
if (textBox.Text.Contains(" "))
{
MessageBox.Show("Sorry, the value entered must not contain any spaces.", "Please enter a valid value", MessageBoxButton.OK, MessageBoxImage.Err
我使用代码来模拟我的silverlight应用程序中的选项卡功能。
我真的希望避免多次编写函数,因为在整个应用程序中,它必须在相当多的文本框上使用。我已经创建了一个静态类
public static class TabInsert
{
private const string Tab = " ";
public static void textBox_KeyDown(object sender, KeyEventArgs e)
{
TextBox textBox = sender as TextBox;
if (e.
由于某些原因,从TextBox到ComboBox,"SelectionStart“属性的行为不同。
创建TextBox和ComboBox。确保DropDownStyle = DropDown (而不是DropDownList!)
添加这些休假事件(如果使用LostFocus事件,结果相同):
Private Sub TextBox1_Leave(sender As Object, e As EventArgs) Handles TextBox1.Leave
Debug.Print("Textbox: " & TextBox1.SelectionStar