D
dennist
I'm opening up a file and putting it's contents into a
textbox. I want to clear the clipboard before setting the
focus to the textbox, but apparently there's no such
animal in vb.net.
Private Sub btnOpenFile_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnOpenFile.Click
Dim StreamR1 As System.IO.StreamReader
OFD1.Filter = ("text files(*.txt)|*.txt|(Word
files(*.doc)|*.doc")
OFD1.ShowDialog()
If OFD1.FileName <> "" Then
Try 'open file and trap any erros using
handler
StreamR1 = New StreamReader(OFD1.FileName)
txtTextGeneral.Text = StreamR1.ReadToEnd
StreamR1.Close()
txtTextGeneral.Select(0, 0)
Catch
MsgBox("Error opening file." & vbCr
& "Perhaps bad file name", , "Error!")
Finally
txtTextGeneral.Focus()
'MsgBox(txtTextGeneral.SelectedText)
End Try
End If
End Sub
don't mind my debugging message box.
Then, when I leave or lose focus of the text box, I want
to set the clipboard to whatever text is selected in the
textbox. There's lot's of funny debugging statements,
please don't laugh too loudly.
Private Sub txtTextGeneral_LostFocus(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
txtTextGeneral.LostFocus
'' Takes the selected text from a text box and
puts it on the clipboard.
'txtTopicTitle.Text = "Leave" 'see leave
'MsgBox("Leave")
'If txtTextGeneral.SelectedText <> "" Then
' Clipboard.SetDataObject
(txtTextGeneral.SelectedText, True)
'Else
' MsgBox("No text selected", , "Warning")
' txtTitle.Text = ""
'End If
End Sub
what I find is that if I click on a control that can
accept text, I get a 'leave' in the topictext box.
Otherwise, nothing happens. No messagebox, no leave, no
nothing. Why can't I do something in vb.net that's as
simple as pie in vb6. Why can't I clear the clipboard.
In the end, everything works out - I think. I'm sure a
user will find differently.
dennist
textbox. I want to clear the clipboard before setting the
focus to the textbox, but apparently there's no such
animal in vb.net.
Private Sub btnOpenFile_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnOpenFile.Click
Dim StreamR1 As System.IO.StreamReader
OFD1.Filter = ("text files(*.txt)|*.txt|(Word
files(*.doc)|*.doc")
OFD1.ShowDialog()
If OFD1.FileName <> "" Then
Try 'open file and trap any erros using
handler
StreamR1 = New StreamReader(OFD1.FileName)
txtTextGeneral.Text = StreamR1.ReadToEnd
StreamR1.Close()
txtTextGeneral.Select(0, 0)
Catch
MsgBox("Error opening file." & vbCr
& "Perhaps bad file name", , "Error!")
Finally
txtTextGeneral.Focus()
'MsgBox(txtTextGeneral.SelectedText)
End Try
End If
End Sub
don't mind my debugging message box.
Then, when I leave or lose focus of the text box, I want
to set the clipboard to whatever text is selected in the
textbox. There's lot's of funny debugging statements,
please don't laugh too loudly.
Private Sub txtTextGeneral_LostFocus(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
txtTextGeneral.LostFocus
'' Takes the selected text from a text box and
puts it on the clipboard.
'txtTopicTitle.Text = "Leave" 'see leave
'MsgBox("Leave")
'If txtTextGeneral.SelectedText <> "" Then
' Clipboard.SetDataObject
(txtTextGeneral.SelectedText, True)
'Else
' MsgBox("No text selected", , "Warning")
' txtTitle.Text = ""
'End If
End Sub
what I find is that if I click on a control that can
accept text, I get a 'leave' in the topictext box.
Otherwise, nothing happens. No messagebox, no leave, no
nothing. Why can't I do something in vb.net that's as
simple as pie in vb6. Why can't I clear the clipboard.
In the end, everything works out - I think. I'm sure a
user will find differently.
dennist