Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.

textBox : add TextChanged events or other events

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-01-2008, 06:25 PM
Newbie
 
Join Date: Aug 2008
Posts: 1
Default textBox : add TextChanged events or other events

Here is a library code source build with sharpdevelop, you can add textChanged events to all you textbox controls :

For #Develop :

Imports System.Windows.Forms
Imports System.Drawing

Public Class txtBox
Implements IDisposable 'Inherit from IDisposable if you need Basic4ppc to free resources when the application is closed.
Private WithEvents myControl As System.Windows.Forms.TextBox'The "real" object.
Public Event TextChanged As EventHandler 'The event handler name must match the event name.
Private eventObject() As Object 'One object[] for each event (one event here).

Sub New( ByVal frm as Form, ByVal txtBox As Control)
Dim ctrl As Windows.Forms.Control
For Each ctrl In frm.Controls
If (ctrl.Name = txtBox.Name) Then
eventObject = New Object() {Me, "TextChanged"}
AddHandler txtBox.TextChanged, AddressOf myControl_TextChanged
Exit Sub
End If
Next
msgbox ("Not Found")
End Sub

Private Sub myControl_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles myControl.TextChanged
RaiseEvent TextChanged(eventObject, Nothing)
End Sub

Public Sub Dispose() Implements System.IDisposable.Dispose
If Not myControl Is Nothing Then
myControl.Dispose()
End If
End Sub
End Class


For Basic4PPC :

Sub App_Start
Form1.Show
sb.New1(Form1.Name,txt.Name)
sb.New1(Form1.Name,cmbDown.Name)
End Sub

Sub sb_TextChanged
Msgbox (txt.Text)
End Sub
Reply With Quote
  #2 (permalink)  
Old 09-01-2008, 06:41 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Thank you for sharing.

This could also be done with the Door library (example from the manual):
Code:
<div align="left"><font face="Courier New"><font color="#008000">'obj is an Object, TextBox1ChangedEvent is an Event.</font></font>
<font face="Courier New"><font color="#0000ff">Sub </font></font><font face="Courier New">App_Start</font>
<font face=
"Courier New">    Form1.Show</font>
<font face=
"Courier New">    obj.New1(false)</font>
<font face=
"Courier New">    obj.FromControl(</font><font face="Courier New"><font color="#800000">"textbox1"</font></font><font face="Courier New">)</font>
<font face=
"Courier New">    TextBox1ChangedEvent.New1( obj.Value,</font><font face="Courier New"><font color="#800000">"TextChanged"</font></font><font face="Courier New">)</font>
<font face=
"Courier New"><font color="#0000ff">End Sub</font></font>

<font face=
"Courier New"><font color="#0000ff">Sub </font></font><font face="Courier New">TextBox1ChangedEvent_NewEvent</font>
<font face=
"Courier New">    form1.Text = textbox1.Text</font>
<font face=
"Courier New"><font color="#0000ff">End Sub</font></font></div>
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Timing between events Zenerdiode Questions (Windows Mobile) 1 08-26-2008 06:34 AM
How to use "Sender" in click-events? Stellaferox Questions (Windows Mobile) 4 02-20-2008 06:00 AM
rapi events stbi Questions (Windows Mobile) 4 10-22-2007 11:55 AM
more events Sven Kommers Basic4ppc Wishlist 3 06-08-2007 09:53 AM
Image Mouse events LineCutter Basic4ppc Wishlist 1 05-19-2007 10:24 AM


All times are GMT. The time now is 10:04 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0