Hello All,
I have got the following code in a program of mine but for some reason what ever i highlight and copy will not paste.
But if i cut text and paste it works fine. Can anyone help?
Code is:
Public Class Form1
Public Sub New()
InitializeComponent()
AddHandler Application.Idle, AddressOf UpdateButtons
End Sub
Protected Overrides Sub OnFormClosing(ByVal e As System.Windows.Forms.FormClosingEventArgs)
RemoveHandler Application.Idle, AddressOf UpdateButtons
MyBase.OnFormClosing(e)
End Sub
Private Sub UpdateButtons(ByVal sender As Object, ByVal e As EventArgs)
Dim box = TryCast(Me.ActiveControl, TextBoxBase)
CopyButton.Enabled = box IsNot Nothing And box.SelectionLength > 0
CutButton.Enabled = CopyButton.Enabled
PasteButon.Enabled = box isnot Nothing and Clipboard.ContainsText
End Sub
Private Sub CopyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyButton.Click
Dim box = TryCast(Me.ActiveControl, TextBoxBase)
If box isnot Nothing then box.Copy()
End Sub
'' etc...
End Class
I have got the following code in a program of mine but for some reason what ever i highlight and copy will not paste.
But if i cut text and paste it works fine. Can anyone help?
Code is:
Public Class Form1
Public Sub New()
InitializeComponent()
AddHandler Application.Idle, AddressOf UpdateButtons
End Sub
Protected Overrides Sub OnFormClosing(ByVal e As System.Windows.Forms.FormClosingEventArgs)
RemoveHandler Application.Idle, AddressOf UpdateButtons
MyBase.OnFormClosing(e)
End Sub
Private Sub UpdateButtons(ByVal sender As Object, ByVal e As EventArgs)
Dim box = TryCast(Me.ActiveControl, TextBoxBase)
CopyButton.Enabled = box IsNot Nothing And box.SelectionLength > 0
CutButton.Enabled = CopyButton.Enabled
PasteButon.Enabled = box isnot Nothing and Clipboard.ContainsText
End Sub
Private Sub CopyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyButton.Click
Dim box = TryCast(Me.ActiveControl, TextBoxBase)
If box isnot Nothing then box.Copy()
End Sub
'' etc...
End Class