Custom Controls TextBox firing TextChanged on Timer

From Visual WebGui Wiki

Jump to: navigation, search


Contents

Overview

This article contains an example of a custom control TextBox that demonstrates how you can add a custom method to the TextBox that your server-side can call and which will update the Value (Text property) of the TextBox, just like when you move the focus to another control.

For the demonstration, a Timer is added to the form that will fire on regular intervals and each time it fires, and there has been a change in the Text of the TextBox, an update is forced and a TextChanged event will fire on the TextBox.

This kind of custom control TextBox could for instance be used (with a Timer control) to serve the purpose of "filtering as you type" behaviour, where you use the TextChanged event for the update.

Version compatibility

This code is written for version 6.4.0 Release d, but should work for any 6.4 version.

Some versions prior to version 6.4.0 Release d, do not have the RegisteredTimers property on the form. If you get build errors for this property, just remove all references to it from the code.

In additon, some references to new Gizmox assemblies might not be available in earlier versions, and they can then safely be removed.

Samples of use

VB.NET Code

Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
    UpdatableTextBox1.doForceTextChange()
End Sub

C# Code

private void timer1_Tick(object sender, EventArgs e)
{
    updatableTextBox1.doForceTextChange();
}

The demo application

Forum discussions

Personal tools