|
I have a richtextbox named
input RTB that I want to associate
its event input RTB.ChangedText to a handler programmatically.
and then it want to use
addhandller and removehandller
to enable the event and to disable it.
can someone help me to achieve
this.
Thank you very much.
|
|
|
|
|
|
Thank you for the response.
before I post my question I browsed Microsoft doc and followed its but that worked
partially .
I succeed to addhandler and it works.
but the removehandler was failed
and the event continue to work.
what I want to achieve is
when my app get input from the user I want
that myevethandler work and
when my app do processing
I want that myeventhandler do
not work.
Again thank you very much
|
|
|
|
|
Sorry, but we cannot guess what you have done wrong. The documentation explains how to use both AddHandler and RemoveHandler . You need to provide full details of what you are doing and why it is not working.
|
|
|
|
|
Hi Richard MacCutchan
This is what I done
Public Class myForm
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
' InputRTB is a richtextbox in myForm
AddHandler InputRTB.TextChanged, AddressOf NewInputTextChanged
End Sub
' slTextBox is a textbox in myForm
Private Sub NewInputTextChanged ' my event handler
slTextBox.Text = InputRTB.Text.Length.ToString
End Sub
' DoButton is a Button in myForm
Private Sub DoButton_Click(sender As Object, e As EventArgs) Handles DoButton.Click
RemoveHandler InputRTB.TextChanged, AddressOf NewInputTextChanged ' disable eventhandler
DoProcess()
AddHandler InputRTB.TextChanged, AddressOf NewInputTextChanged ' enable eventhandler
End Sub
. . .
End Class
Thank you very much
|
|
|
|
|
Look at your code in the button click event, it does the following:
1. Removes the handler
2. Calls some method
3. Adds the handler back again
RemoveHandler InputRTB.TextChanged, AddressOf NewInputTextChanged
DoProcess()
AddHandler InputRTB.TextChanged, AddressOf NewInputTextChanged
So as soon as this event is complete you have the handler catching every TextChanged event again.
|
|
|
|
|
its ok after the method is finished.
but the problem is inside the method that had access the inputRTB
textbox and cause interference
because of the event continue
to work a d that seams as removehandler called before the
method not working.
I'm thank you very much
for your efforts to help me.
|
|
|
|
|
Sorry, but I don't understand. And I have no idea what the DoProcess method is doing.
|
|
|
|
|
DoProcess manipulate the text of inputRTB and because the event still work
that cause DoProcess to be hanging.
When I run DoProcess without these addhandler removehandler events
DoProcess run smoothly and quickly.
But with them its hang.
again I'm very thank you.
|
|
|
|
|
|
OK, I have got it working (I think). You need the following changes to your code:
Dim handler As EventHandler
Public Sub New()
MyBase.New()
InitializeComponent()
handler = AddressOf NewInputTextChanged
AddHandler InputRTB.TextChanged, handler
End Sub
Private Sub NewInputTextChanged()
slTextBox.Text = InputRTB.Text.Length.ToString
End Sub
Private Sub DoButton_Click(sender As Object, e As EventArgs) Handles DoButton.Click
RemoveHandler InputRTB.TextChanged, handler
DoProcess()
AddHandler InputRTB.TextChanged, handler
End Sub
|
|
|
|
|
Hi Richard MacCutchan
Bravo !
You did it.
I'm very very Thank You. !!!
|
|
|
|
|
It was not easy to find, since your original code compiled correctly. It was only when I noticed a warning in Visual Studio that I was able to find the answer.
|
|
|
|
|
I was afraid that you give up
|
|
|
|
|
Sometimes I do, sometimes I don't. Your lucky day today; unless you are self-isolating from COVID-19.
|
|
|
|
|
|
Member 13569650 wrote: but the removehandler was failed
and the event continue to work.
Define "failed".
|
|
|
|
|
Hello everyone. I started a project which is suppose to utilize SOAP API and the URL they provide is a WSDL extension (Here is the URL: http://api.netim.com/2.0/api.wsdl)
Maybe I'm wrong, but WSDL's are suppose to be added as Web References, correct?
I've tried adding as both a service reference and web reference with the URL above and it always returns a 404 error. But, as you can see by visiting the URL above it works fine in a browser. Any idea what I'm doing wrong here? Thanks in advance!
|
|
|
|
|
j'ai une base de donnée Admin et une autre PersonneActive et je souhaiterais recuperer les info dela table Admin pour l'inserer dans la table PersonneActive mais mon soucis c'est qu'il s'enregistre duex et je ne c'est pourquoi.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If TxtUser.Text = Nothing Or TxtPassWord.Text = Nothing Then
MsgBox("Veuillez renseigner tous les champs", MsgBoxStyle.Exclamation)
Else
If cnx.State = ConnectionState.Closed Then
cnx.Open()
End If
'VERIFER LES ENREGISTREMENTS DANS LA BASE DE DONNEE
'cnx.Open()
Dim searchQuery As String = "select count(*) from Admin WHERE RefAdmin=? and MotDePasse=?"
Dim Command As New OleDbCommand(searchQuery, cnx)
Command.Parameters.AddWithValue("@1", OleDbType.VarChar).Value = TxtUser.Text
Command.Parameters.AddWithValue("@2", OleDbType.VarChar).Value = TxtPassWord.Text
Dim count = Convert.ToInt32(Command.ExecuteScalar())
If (count > 0) Then
MsgBox("Mot de passe validé avec succès'" & TxtUser.Text & "'", MsgBoxStyle.Information)
'DECLARATION DES VARIABLES
Dim motpass, nom, dateactive As String
motpass = TxtPassWord.Text
nom = TxtUser.Text
dateactive = DateAndTime.Now()
Dim insert2 As String = "INSERT INTO [PersonneActive] ([MotPasseActive], [NomActive], [DateActive]) VALUES (@motpass, @nom, @dateactive)"
Using cmd As New OleDbCommand(insert2, cnx)
'cmd.Parameters.AddWithValue("", 1)
cmd.Parameters.AddWithValue("@1", OleDbType.VarChar).Value = TxtPassWord.Text
cmd.Parameters.AddWithValue("@2", OleDbType.VarChar).Value = TxtUser.Text
cmd.Parameters.AddWithValue("@3", OleDbType.VarChar).Value = DateAndTime.Now()
'cmd.Parameters.AddWithValue("@confirmotpass", confirmotpass)
cmd.ExecuteNonQuery()
End Using
TxtUser.Text = ""
TxtPassWord.Text = ""
Me.Hide()
Form1.Show()
Else
MsgBox("Problème avec le mot de passe ou Compte intouvable... Veuillez contacter l'administrateur AGO KOUAME BERTRAND", MsgBoxStyle.Critical)
TxtUser.Text = ""
TxtPassWord.Text = ""
End If
End If
'Dim adapter As New OleDbDataAdapter(Command)
'Dim ds As New DataSet
'Dim table As New DataTable
'adapter.Fill(ds, "CERTIFICAT")
'DataGridView1.DataSource = ds.Tables("CERTIFICAT")
'adapter.Dispose()
Catch ex As Exception
MsgBox(ex.Message)
Finally
cnx.Close()
End Try
End Sub
|
|
|
|
|
|
i am thinking of developing a restaurant billing system.
here is how my set up going to be.
1 desktop PC(SQLServer) to run SQL server. OS windows server.
2 desktop PCs(Cashier1,Cashier2) for cashiers.
SQLServer, Cashier1 and Cashier2 will be connected to local network(wired)
5 Tablet for waiters to take orders (enter orders to SQLServer). These Tablets will have wifi connections to enter customer orders into SQLServer
bills will be printed from Cashier1 and Cashier2
5 Tablets will be using unique user logins to take orders.
now my question is. will it be too slow or the system will hang when staffs use tablets to take orders?
|
|
|
|
|
Meax wrote: now my question is. will it be too slow or the system will hang when staffs use tablets to take orders? Should work without problems, even on a slow network. It's not like you will be downloading a lot of data for placing an order.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
my client having doubts. saying that tablets will hang and slow.
currently they are using ipads and running the application by remote desktop.
billing system is installed in a PC and waiters are using ipads via remote desktop to make entries.
at the moment they are facing lot of problems. every now and then their ipads remote access connections gets disconnected. and sometimes even wifi connections are getting lost.
so, i proposed my methodology(explained in the original post). but my client having doubts. saying tablets will face same issue as ipads.
|
|
|
|
|
Don't run it as a remote desktop application. Either have a native app on the tablet, or use a web application.
And if the wifi connections are getting lost, you need to install some wifi boosters. Nothing you can do in your code will solve that.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sounds your client already made up his mind about it, but should be as fast on a tablet as loading the average webpage.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|