|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
TextChangedTextBox.TextChanged Event fires even when the text is changed
programatically. How can I detect that the text has been changed by the user and not changed programatically? Thanks Hi look at the
Keydown or keyup event Greetz Peter Show quoteHide quote "Nice Chap" <NiceC***@PlasmaDyne.com> schreef in bericht news:e8BWVqDPFHA.3076@tk2msftngp13.phx.gbl... > TextBox.TextChanged Event fires even when the text is changed > programatically. How can I detect that the text has been changed by the user > and not changed programatically? > > Thanks > > Don't forget the MouseDown/MouseUp events, in case the user pastes text by
right-clicking and selecting Paste on the popup menu (if any). Show quoteHide quote "Peter Proost" <pproost@nospam.hotmail.com> wrote in message news:%23gbvItDPFHA.3076@tk2msftngp13.phx.gbl... > Hi look at the > > Keydown or keyup event > > Greetz Peter > > > "Nice Chap" <NiceC***@PlasmaDyne.com> schreef in bericht > news:e8BWVqDPFHA.3076@tk2msftngp13.phx.gbl... > > TextBox.TextChanged Event fires even when the text is changed > > programatically. How can I detect that the text has been changed by the > user > > and not changed programatically? > > > > Thanks > > > > > > Nice Chap,
Two ways. Set a Boolean switch to evaluate that in the event or delete the handler when you do it programmatically When you do it programmatically (and set it (back) afterwards) I hope this helps, Cor "Nice Chap" <NiceC***@PlasmaDyne.com> schrieb: You may want to set a flag (for example, by setting the control's 'Tag' > TextBox.TextChanged Event fires even when the text is changed > programatically. How can I detect that the text has been changed by the > user and not changed programatically? property) before changing the value programmatically and check this flag in the 'TextChanged' event handler. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
>You may want to set a flag (for example, by setting the control's 'Tag' Is using that tag for that an idea from VBCom (I saw Larry once doing that), >property) I don't see the benefit from it. However maybe can you explain that too me(serious) Cor "Cor Ligthert" <notmyfirstn***@planet.nl> schrieb: Using the 'Tag' property might be easier because you don't need any >>You may want to set a flag (for example, by setting the control's 'Tag' >>property) > > Is using that tag for that an idea from VBCom (I saw Larry once doing > that), I don't see the benefit from it. > > However maybe can you explain that too me(serious) additional private variables. However, it's one of many possible solutions and its up to personal preference whether to use 'Tag' or not. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
I find (and found it forever) wrong to use datafields that have no descriptive names only to save 1 machineword. (that forever was a while after the time that I was using relays, however than we could not give that relay a descriptive name). However it sounds for me a behaviour from that time. I hope you agree that. Cor Ok, I've read all of the other responses, but I have to ask: "Why do you have to tell it
to do anything." Simply Dim a "global" variable as a string and then do this: Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles TextBox1.TextChanged myvariable = TextBox1.Text End Sub it detects any changes. Or is there something wrong with doing this.?? -- Show quoteHide quoteSteve Easton Microsoft MVP FrontPage 95isalive This site is best viewed.................. ...............................with a computer "Nice Chap" <NiceC***@PlasmaDyne.com> wrote in message news:e8BWVqDPFHA.3076@tk2msftngp13.phx.gbl... > TextBox.TextChanged Event fires even when the text is changed > programatically. How can I detect that the text has been changed by the user > and not changed programatically? > > Thanks > >
Show quote
Hide quote
"95isalive" <ad***@95isalive.com> schrieb; Well, the OP wants tol execute the code 'myvariable = TextBox1.Text' only if > Ok, I've read all of the other responses, but I have to ask: "Why do you > have to tell it > to do anything." > > Simply Dim a "global" variable as a string and then do this: > > Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As > _ > System.EventArgs) Handles TextBox1.TextChanged > > myvariable = TextBox1.Text > > End Sub > > it detects any changes. > > Or is there something wrong with doing this.?? the text has been changed by the user and not when it was changed programmatically. \\\ Private Sub TextBox1_TextChanged( _ ByVal sender As Object, _ ByVal e As EventArgs _ ) Handles TextBox1.TextChanged If Not DirectCast(sender, Control).Tag Then ... End If End Sub .. .. .. With Me.TextBox1 .Tag = True .Text = "Hello World!" .Tag = False End With /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Or making it in my opinion as syntax nicer using Herfrieds sample
dim SwProramTextBox1Change as boolean Private Sub TextBox1_TextChanged( _ ByVal sender As Object, _ ByVal e As EventArgs _ Handles TextBox1.TextChanged If Not SwProgramTextBox1Change Then ... End If SwProgramChange = False End Sub /// \\\ SwProgramTextbox1Change = True MeTextBox1.Text = "Hello World!" /// :-) CorCor,
Show quoteHide quote "Cor Ligthert" <notmyfirstn***@planet.nl> schrieb: I thought about resetting the flag inside the 'TextChanged' event handler > Or making it in my opinion as syntax nicer using Herfrieds sample > > dim SwProramTextBox1Change as boolean > Private Sub TextBox1_TextChanged( _ > ByVal sender As Object, _ > ByVal e As EventArgs _ > Handles TextBox1.TextChanged > If Not SwProgramTextBox1Change Then > ... > End If > SwProgramChange = False > End Sub > /// > \\\ > SwProgramTextbox1Change = True > MeTextBox1.Text = "Hello World!" > /// too but then decided not to do that. By letting the user reset the property/flag manually consecutive changes of the textbox's content are possible. \\\ With Me.TextBox1 .Tag = True For i = 1 To 20 ... If ... Then .Text = ... End If Next i .Tag = False End With /// The code above will not execute the code in the 'TextChanged' event handler even if the textbox' text is changed more than once. Just my 2 Euro cents... -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
My main thing is that using a Tag (just because it is there) for what it is not created for is in my opinion not right. (You know it is friday evening and you know what that means, so I don't go in discussion anymore) I think you are right about the side effect what you wrote. However don't shoot me at the moment when I did understand you wrong. :-)) CorCor,
"Cor Ligthert" <notmyfirstn***@planet.nl> schrieb: Mhm... I don't think that the use of 'Tag' shown in my sample is that bad, > My main thing is that using a Tag (just because it is there) for what it > is not created for is in my opinion not right. (You know it is friday > evening and you know what that means, so I don't go in discussion anymore) but as I already said, I accept that other people choose another solution. Show quoteHide quote > I think you are right about the side effect what you wrote. However don't > shoot me at the moment when I did understand you wrong. :-) -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
stringbuilder replace doesn't work on vbLf , vbCrLf , vbCr
Regular Expression to Parse HTML Sending Mail using dotNET Create Short Cut sending bytes DATAGRID+SQL: INSERT - works, but SELECT - not :-( openfiledialog control locks folder Any similar comment line like ' TODO : sending string Sending DTMF Tones |
|||||||||||||||||||||||