Hi,
I have MDIform as well as form2 in my project. From MDI, i am opening child form-form2 and populating a richtextbox with a text file content. Also i am populating a listbox on that form.
unfortunately i am getting 'Object Reference not set' error on richtextbox loadfile line...
---menu code that opens form2 and populate richtextbox
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
StatusBar1.Text = "Ready"
OpenFileDialog1.Filter = "WDL files (*.wdl)|*.txt|All files (*.*)|*.*"
OpenFileDialog1.ShowDialog()
Class1.f2.richtextbox1.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText))
Class1.f2.Show()
StatusBar1.Text = OpenFileDialog1.FileName & " file opened."
End Sub
-----------------------------------
Also how do i add values to the listbox on form2 from mdiform?
I tried- Class1.f2.varlist.Items.Add("test")
unsuccessfull....
----my startup is sub_main which shares two forms----
Public Class Class1
Public Shared f1 As Form1 = Form1.ActiveForm
Public Shared f2 As Form2
Public Shared Sub Main()
f1 = New Form1()
f2 = New Form2()
f1.Show()
Application.Run()
End Sub
End Class
----------------------------------------------------------------------
thanks in advance for any help...
I have MDIform as well as form2 in my project. From MDI, i am opening child form-form2 and populating a richtextbox with a text file content. Also i am populating a listbox on that form.
unfortunately i am getting 'Object Reference not set' error on richtextbox loadfile line...
---menu code that opens form2 and populate richtextbox
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
StatusBar1.Text = "Ready"
OpenFileDialog1.Filter = "WDL files (*.wdl)|*.txt|All files (*.*)|*.*"
OpenFileDialog1.ShowDialog()
Class1.f2.richtextbox1.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText))
Class1.f2.Show()
StatusBar1.Text = OpenFileDialog1.FileName & " file opened."
End Sub
-----------------------------------
Also how do i add values to the listbox on form2 from mdiform?
I tried- Class1.f2.varlist.Items.Add("test")
unsuccessfull....
----my startup is sub_main which shares two forms----
Public Class Class1
Public Shared f1 As Form1 = Form1.ActiveForm
Public Shared f2 As Form2
Public Shared Sub Main()
f1 = New Form1()
f2 = New Form2()
f1.Show()
Application.Run()
End Sub
End Class
----------------------------------------------------------------------
thanks in advance for any help...