TextBox Text Changed Event : TextBox « GUI « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » GUI » TextBox 
14.23.6.TextBox Text Changed Event
TextBox Text Changed Event
imports System
imports System.Drawing
imports System.Windows.Forms

public class TextBoxTextChanged : inherits Form

  dim txt as TextBox
  dim btn as Button
  dim strOriginal as string

  public sub New()
        Text = "TextBox Modified and TextChanged"
    Size = new Size(300375)

    txt = new TextBox()
    txt.Parent = me
    txt.Text = "Enter text here."
    txt.Size = new Size(280275)
    txt.Location = new Point(10,10)
    AddHandler txt.TextChanged, AddressOf txt_TextChanged
    txt.Multiline = true
    txt.BorderStyle = BorderStyle.Fixed3D
    txt.ScrollBars = ScrollBars.Vertical
    txt.Anchor = AnchorStyles.Left or AnchorStyles.Right or AnchorStyles.Top or AnchorStyles.Bottom
    strOriginal = txt.Text

    btn = new Button()
    btn.Parent = me
    btn.Text = "Check "
    btn.Location = new Point(20,320)
    AddHandler btn.Click, AddressOf btn_Click
    btn.Anchor = AnchorStyles.Bottom

  end sub

  public shared sub Main() 
    Application.Run(new TextBoxTextChanged())
  end sub

  private sub txt_TextChanged(ByVal sender as object,ByVal e as EventArgs)
    Console.WriteLine("txt_TextChanged")
    if strOriginal = txt.Text then
      txt.Modified = false
    else
      txt.Modified = true
    end if
  end sub

  private sub btn_Click(ByVal sender as object,ByVal e as EventArgs)
    if txt.Modified then
      Console.WriteLine("modified.")
      strOriginal = txt.Text
      txt.Modified = false
    else
      Console.WriteLine("not been modified." )
    end if
  end sub
end class
14.23.TextBox
14.23.1.Get input from TextBox and Set to LabelGet input from TextBox and Set to Label
14.23.2.Convert input value in a TextFieldConvert input value in a TextField
14.23.3.Inherit TextBox to create custom control based on TextBox
14.23.4.Display text file in a TextBoxDisplay text file in a TextBox
14.23.5.Numeric TextBoxNumeric TextBox
14.23.6.TextBox Text Changed EventTextBox Text Changed Event
14.23.7.Comprehensive Demo for TextBoxComprehensive Demo for TextBox
14.23.8.Change TextBox font by RadioButton and CheckBoxChange TextBox font by RadioButton and CheckBox
14.23.9.Get selected text in TextBoxGet selected text in TextBox
14.23.10.Create PasswordField by setting the TextBox.PasswordCharCreate PasswordField by setting the TextBox.PasswordChar
14.23.11.Copy selection text from a TextBox and paste to anotherCopy selection text from a TextBox and paste to another
14.23.12.Multiline Text BoxesMultiline Text Boxes
14.23.13.Disable TextBox Context MenuDisable TextBox Context Menu
14.23.14.Save text in TextBox to a file
14.23.15.Handles the Click event of a Button to change the background color of a TextBox.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.