对非共享对象的RichTextBox1引用需要一个对象引用

时间:2018-11-23 06:07:36

标签: vb.net winforms richtextbox

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)上的错误

错误是:

  

引用非共享成员需要对象引用

0 个答案:

没有答案