Good morning forum,
I was wondering if what I'm doing is correct or if there is a better way. I have a Tab Control and I add tab page at run-time. Each page contains a richtextbox. When the user clicks the save all documents button it will save the text inside the richtextbox to its file. This following code loops through each tab and does what I mentioned above. When I create the page I add the file location to the tag property of the RIchTextBox. What I am worried about is the
part. Is there a different way to get that control even if its index 0, 1, 2? also what if the control was inside a panel which sits inside the TabPage. Would I then have to loop through each page, find the panel, then find the RichTextBox?
I was wondering if what I'm doing is correct or if there is a better way. I have a Tab Control and I add tab page at run-time. Each page contains a richtextbox. When the user clicks the save all documents button it will save the text inside the richtextbox to its file. This following code loops through each tab and does what I mentioned above. When I create the page I add the file location to the tag property of the RIchTextBox. What I am worried about is the
Code:
myTabPages.Controls(0)
Code:
For Each myTabPages As TabPage In TabControl1.TabPages
Dim iDocument = CType(myTabPages.Controls(0), RichTextBox)
If iDocument.Modified = True Then
Dim objwriter As New IO.StreamWriter(iDocument.Tag, False)
objwriter.WriteLine(iDocument.Text())
objwriter.Close()
iDocument.Modified = False
End If
Next