473,657 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

textbox delete and undo

I have created my own context menu. Everything works except undo'ing
deleted text. My code for these two events are:

Private Sub tsmiUndo_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiUndo.Click

' Undo the last thing the user did and clear the undo buffer to make
sure that clicking
' Undo again doesn't redo the last thing undone.

Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.CanUndo = True Then
tb.Undo()
tb.ClearUndo()
End If

Does anyone have an idea of why this doesn't work?

Thanks

Steve

End Sub

Private Sub tsmiDelete_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiDelete.Clic k

' Delete the selected text (if any) by initalizing the textbox.
If (TypeOf Me.ActiveContro l Is TextBox) Then
Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.SelectionLen gth 0 Then
tb.SelectedText = ""
End If
End If

End Sub
Dec 29 '06 #1
5 5596
Steve,

I tested it in version 2003 but works perfectly for me.

Cor

"Steve" <s.*****@comcas t.netschreef in bericht
news:ul******** ******@TK2MSFTN GP04.phx.gbl...
>I have created my own context menu. Everything works except undo'ing
deleted text. My code for these two events are:

Private Sub tsmiUndo_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiUndo.Click

' Undo the last thing the user did and clear the undo buffer to
make
sure that clicking
' Undo again doesn't redo the last thing undone.

Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.CanUndo = True Then
tb.Undo()
tb.ClearUndo()
End If

Does anyone have an idea of why this doesn't work?

Thanks

Steve

End Sub

Private Sub tsmiDelete_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiDelete.Clic k

' Delete the selected text (if any) by initalizing the textbox.
If (TypeOf Me.ActiveContro l Is TextBox) Then
Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.SelectionLen gth 0 Then
tb.SelectedText = ""
End If
End If

End Sub


Dec 29 '06 #2
Thanks for testing...

Are you remembering that you have to set the contextmenuscri pt in the
textbox properties to your contextmenuscri pt instead of the default?

Steve

"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:OH******** ******@TK2MSFTN GP04.phx.gbl...
Steve,

I tested it in version 2003 but works perfectly for me.

Cor

"Steve" <s.*****@comcas t.netschreef in bericht
news:ul******** ******@TK2MSFTN GP04.phx.gbl...
I have created my own context menu. Everything works except undo'ing
deleted text. My code for these two events are:

Private Sub tsmiUndo_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiUndo.Click

' Undo the last thing the user did and clear the undo buffer to
make
sure that clicking
' Undo again doesn't redo the last thing undone.

Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.CanUndo = True Then
tb.Undo()
tb.ClearUndo()
End If

Does anyone have an idea of why this doesn't work?

Thanks

Steve

End Sub

Private Sub tsmiDelete_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiDelete.Clic k

' Delete the selected text (if any) by initalizing the textbox.
If (TypeOf Me.ActiveContro l Is TextBox) Then
Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.SelectionLen gth 0 Then
tb.SelectedText = ""
End If
End If

End Sub


Dec 29 '06 #3
One more note. If I don't set the textbox's contextmenuscri pt property
equal to the contextmenuscri pt you added, then the textbox works using the
default (set to none). But if you set it to the contextmenuscri pt field you
added, it doesn't appear to work. I tried it in a new 2005 project with two
textboxes and the contextmenuscri pt (with two items - delete and undo) -
same result.

Steve

"Steve" <s.*****@comcas t.netwrote in message
news:%2******** **********@TK2M SFTNGP02.phx.gb l...
Thanks for testing...

Are you remembering that you have to set the contextmenuscri pt in the
textbox properties to your contextmenuscri pt instead of the default?

Steve

"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:OH******** ******@TK2MSFTN GP04.phx.gbl...
Steve,

I tested it in version 2003 but works perfectly for me.

Cor

"Steve" <s.*****@comcas t.netschreef in bericht
news:ul******** ******@TK2MSFTN GP04.phx.gbl...
>I have created my own context menu. Everything works except undo'ing
deleted text. My code for these two events are:
>
Private Sub tsmiUndo_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiUndo.Click
>
' Undo the last thing the user did and clear the undo buffer to
make
sure that clicking
' Undo again doesn't redo the last thing undone.
>
Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.CanUndo = True Then
tb.Undo()
tb.ClearUndo()
End If
>
Does anyone have an idea of why this doesn't work?
>
Thanks
>
Steve
>
End Sub
>
Private Sub tsmiDelete_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiDelete.Clic k
>
' Delete the selected text (if any) by initalizing the textbox.
>
>
If (TypeOf Me.ActiveContro l Is TextBox) Then
Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.SelectionLen gth 0 Then
tb.SelectedText = ""
End If
End If
>
End Sub
>
>


Dec 29 '06 #4
Hi Steve,

use tb.cut() instead of tb.SelectedText = "" and you should find that undo
will work then.

HTH

Martin
"Steve" <s.*****@comcas t.netwrote in message
news:ul******** ******@TK2MSFTN GP04.phx.gbl...
>I have created my own context menu. Everything works except undo'ing
deleted text. My code for these two events are:

Private Sub tsmiUndo_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiUndo.Click

' Undo the last thing the user did and clear the undo buffer to
make
sure that clicking
' Undo again doesn't redo the last thing undone.

Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.CanUndo = True Then
tb.Undo()
tb.ClearUndo()
End If

Does anyone have an idea of why this doesn't work?

Thanks

Steve

End Sub

Private Sub tsmiDelete_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiDelete.Clic k

' Delete the selected text (if any) by initalizing the textbox.
If (TypeOf Me.ActiveContro l Is TextBox) Then
Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.SelectionLen gth 0 Then
tb.SelectedText = ""
End If
End If

End Sub


Dec 30 '06 #5
I ended up discovering that through trial and error. So I guess that undo
pulls from the clipboard instead of an undo buffer?

"Martin Horn" <te**@test.comw rote in message
news:JI******** ***********@new sfe6-gui.ntli.net...
Hi Steve,

use tb.cut() instead of tb.SelectedText = "" and you should find that undo
will work then.

HTH

Martin
"Steve" <s.*****@comcas t.netwrote in message
news:ul******** ******@TK2MSFTN GP04.phx.gbl...
I have created my own context menu. Everything works except undo'ing
deleted text. My code for these two events are:

Private Sub tsmiUndo_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiUndo.Click

' Undo the last thing the user did and clear the undo buffer to
make
sure that clicking
' Undo again doesn't redo the last thing undone.

Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.CanUndo = True Then
tb.Undo()
tb.ClearUndo()
End If

Does anyone have an idea of why this doesn't work?

Thanks

Steve

End Sub

Private Sub tsmiDelete_Clic k(ByVal sender As Object, ByVal e As
System.EventArg s) Handles tsmiDelete.Clic k

' Delete the selected text (if any) by initalizing the textbox.
If (TypeOf Me.ActiveContro l Is TextBox) Then
Dim tb As TextBox = CType(Me.Active Control, TextBox)
If tb.SelectionLen gth 0 Then
tb.SelectedText = ""
End If
End If

End Sub


Dec 31 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7841
by: Susan Bricker | last post by:
I have a command button on a form that is supposed to Delete the record being displayed. The record is displayed one to a form. The form is not a Pop-Up nor is it Modal. Tracing the btnDelete event routine shows that AllowDeletions is TRUE. When the Delete button is clicked (without TRACE ON), I get a 'beep', the recordselector (vertical bar on left of form) gets dark in color, but the record is not deleted. Also, there is no error...
6
3710
by: Altramagnus | last post by:
I have searched throught the newsgroups on how to restrict entry in textboxes, for example, I only want the textbox to only accept numberic. The standard answer is to use the KeyPress event. However, this do not address the paste event User is still able to copy and paste any characters. How do I create a textbox so that regardless what I do ( including cut and paste ),
0
1728
by: Marco Liedekerken | last post by:
Hi, If a user enters a wrong value (which depends on some properties of it's container control) in one of my dynamicly made TextBoxes I want to undo the change he made to the Text property of the TextBox. I think some possible ways are: - Use a Validation control. This will be difficult because I generate multiple TextBoxes dynamicly and they have different validationrules. - Do something in the TextChanged handler. This is preferred...
0
228
by: Crouchie1998 | last post by:
How do I totally override the textbox context menu? I mean remove the standard copy/paste/undo/delete I do not want to create my own context menu using the context menu control Any suggestions?
6
2096
by: bobdydd | last post by:
Access 2000 Windows XP Hi Everybody I have got a weird one here. I have a large form frmTransactions based on a single table tblTransactions. There are a lot of fields on the form but everything works OK. That is
2
3009
by: Mike Fox | last post by:
I am trying to implement undo in an application. The problem is the user wants a granular undo like word or studio. Here's the issue: 1. Bring up a record, and edit a field. 2. move to a new field and edit 3. delete the record 4. Now hit undo. If I "undo" the delete using datarow.undo() or datarow.rejectchanges(), it reverts to the original state and I lose the changes fromstep 1 and 2. The user wants to be able to undo JUST the...
10
2454
by: garyusenet | last post by:
I have a multiline textbox. The size of the text box should be 75 characters wide, and 5 lines in height like this: - <---75 characters--> <---75 characters--> <---75 characters--> <---75 characters--> <---75 characters-->
5
8153
WyvsEyeView
by: WyvsEyeView | last post by:
Upon clicking Delete to delete the current record on frmTopics, I want several things to happen: 1) Display a custom message rather than Access's standard "You are about to delete n records" one. 2) Delete the record. 3) Delete all related attribute records. 4) Go to a new record. Here is my code: Private Sub cmdDelete_Click()
6
6518
by: xenocidecrash | last post by:
I am using: C#, .Net, Windows Forms I have created a derived class from the System.Windows.Forms.TextBox class that only allows hexadecimal characters to be entered, whether typed or pasted. (pasting just strips out all non-hex characters). It works fine except for the fact that I can't undo after pasting into the box. I feel this must have something to do with the fact that I took over WindProc for the WM_PASTE message, but I'm not sure...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.