Class DragDropRichTextBox
Inherits RichTextBox
Public Sub DragDropRichTextBox()
Me.AllowDrop = True
AddHandler Me.DragDrop, AddressOf richTextBox1_DragDrop
End Sub
Public Sub richTextBox1_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs)
Dim filename As Object = e.Data.GetData("FileDrop")
If filename IsNot Nothing Then
Dim list = TryCast(filename, String())
If list IsNot Nothing AndAlso Not String.IsNullOrWhiteSpace(list(0)) Then
RichTextBox1.Clear()
RichTextBox1.LoadFile(list(0), RichTextBoxStreamType.PlainText)
End If
End If
End Sub
End Class
RichTextBox1.clear()
和RichTextBox1.LoadFile(list(0), RichTextBoxStreamType.PlainText)
上的错误
错误是:
引用非共享成员需要对象引用