|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
textbox delete and undodeleted text. My code for these two events are: Private Sub tsmiUndo_Click(ByVal sender As Object, ByVal e As System.EventArgs) 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.ActiveControl, 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_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsmiDelete.Click ' Delete the selected text (if any) by initalizing the textbox. If (TypeOf Me.ActiveControl Is TextBox) Then Dim tb As TextBox = CType(Me.ActiveControl, TextBox) If tb.SelectionLength > 0 Then tb.SelectedText = "" End If End If End Sub Steve,
I tested it in version 2003 but works perfectly for me. Cor Show quoteHide quote "Steve" <s.ar***@comcast.net> schreef in bericht news:uloaRoxKHHA.3268@TK2MSFTNGP04.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.EventArgs) 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.ActiveControl, 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_Click(ByVal sender As Object, ByVal e As > System.EventArgs) Handles tsmiDelete.Click > > ' Delete the selected text (if any) by initalizing the textbox. > > > If (TypeOf Me.ActiveControl Is TextBox) Then > Dim tb As TextBox = CType(Me.ActiveControl, TextBox) > If tb.SelectionLength > 0 Then > tb.SelectedText = "" > End If > End If > > End Sub > > Thanks for testing...
Are you remembering that you have to set the contextmenuscript in the textbox properties to your contextmenuscript instead of the default? Steve Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OH5gQdyKHHA.3268@TK2MSFTNGP04.phx.gbl... > Steve, > > I tested it in version 2003 but works perfectly for me. > > Cor > > "Steve" <s.ar***@comcast.net> schreef in bericht > news:uloaRoxKHHA.3268@TK2MSFTNGP04.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.EventArgs) 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.ActiveControl, 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_Click(ByVal sender As Object, ByVal e As > > System.EventArgs) Handles tsmiDelete.Click > > > > ' Delete the selected text (if any) by initalizing the textbox. > > > > > > If (TypeOf Me.ActiveControl Is TextBox) Then > > Dim tb As TextBox = CType(Me.ActiveControl, TextBox) > > If tb.SelectionLength > 0 Then > > tb.SelectedText = "" > > End If > > End If > > > > End Sub > > > > > > One more note. If I don't set the textbox's contextmenuscript property
equal to the contextmenuscript you added, then the textbox works using the default (set to none). But if you set it to the contextmenuscript field you added, it doesn't appear to work. I tried it in a new 2005 project with two textboxes and the contextmenuscript (with two items - delete and undo) - same result. Steve Show quoteHide quote "Steve" <s.ar***@comcast.net> wrote in message news:%23Lky%23n2KHHA.1248@TK2MSFTNGP02.phx.gbl... > Thanks for testing... > > Are you remembering that you have to set the contextmenuscript in the > textbox properties to your contextmenuscript instead of the default? > > Steve > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:OH5gQdyKHHA.3268@TK2MSFTNGP04.phx.gbl... > > Steve, > > > > I tested it in version 2003 but works perfectly for me. > > > > Cor > > > > "Steve" <s.ar***@comcast.net> schreef in bericht > > news:uloaRoxKHHA.3268@TK2MSFTNGP04.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.EventArgs) 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.ActiveControl, 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_Click(ByVal sender As Object, ByVal e As > > > System.EventArgs) Handles tsmiDelete.Click > > > > > > ' Delete the selected text (if any) by initalizing the textbox. > > > > > > > > > If (TypeOf Me.ActiveControl Is TextBox) Then > > > Dim tb As TextBox = CType(Me.ActiveControl, TextBox) > > > If tb.SelectionLength > 0 Then > > > tb.SelectedText = "" > > > End If > > > End If > > > > > > End Sub > > > > > > > > > > > > Hi Steve,
use tb.cut() instead of tb.SelectedText = "" and you should find that undo will work then. HTH Martin Show quoteHide quote "Steve" <s.ar***@comcast.net> wrote in message news:uloaRoxKHHA.3268@TK2MSFTNGP04.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.EventArgs) 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.ActiveControl, 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_Click(ByVal sender As Object, ByVal e As > System.EventArgs) Handles tsmiDelete.Click > > ' Delete the selected text (if any) by initalizing the textbox. > > > If (TypeOf Me.ActiveControl Is TextBox) Then > Dim tb As TextBox = CType(Me.ActiveControl, TextBox) > If tb.SelectionLength > 0 Then > tb.SelectedText = "" > End If > End If > > End Sub > > I ended up discovering that through trial and error. So I guess that undo
pulls from the clipboard instead of an undo buffer? Show quoteHide quote "Martin Horn" <t***@test.com> wrote in message news:JItlh.26347$Qa6.12386@newsfe6-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.ar***@comcast.net> wrote in message > news:uloaRoxKHHA.3268@TK2MSFTNGP04.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.EventArgs) 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.ActiveControl, 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_Click(ByVal sender As Object, ByVal e As > > System.EventArgs) Handles tsmiDelete.Click > > > > ' Delete the selected text (if any) by initalizing the textbox. > > > > > > If (TypeOf Me.ActiveControl Is TextBox) Then > > Dim tb As TextBox = CType(Me.ActiveControl, TextBox) > > If tb.SelectionLength > 0 Then > > tb.SelectedText = "" > > End If > > End If > > > > End Sub > > > > > >
VB2005 registering a dll
How do I sort an ArrayList of objects by a property value working with Access in VB.Net Deleting directory path and files. VB.net 2003 how to check if the dataset is EOF or if a record exists frist . Change Connection String during runtime Upgrade for Deployment Purposes how to start explorer to console app location? listbox datatable selected item Format Textbox How & Where?? |
|||||||||||||||||||||||