jwcoleman87
Well-known member
- Joined
- Oct 4, 2014
- Messages
- 124
- Programming Experience
- Beginner
Dim CommentsTab As New TabPage With {.Name = "Comments", .Text = "Add Comments"} TabControl1.TabPages.Add(CommentsTab) Dim flpcomments As New FlowLayoutPanel With {.Parent = TabControl1.TabPages("Comments"), .Dock = DockStyle.Fill, .BorderStyle = BorderStyle.Fixed3D} Dim txtComments As New TextBox With {.Parent = flpcomments} Dim btnSave As New Button With {.Parent = flpcomments, .Text = "Save"}
So lets say I create a tab page, assign it to a tab control, add a flowlayoutpanel to that tabpage, and create a textbox and button in that flowlayoutpanel in that tabpage in that tab control.
I began writing a handler that would handle the clicking of the save button, but then I realized I was missing the textbox part. The comment would be contained in the textbox and would be needed to be passed as a parameter to whatever function the handler will call in order to "save a comment"
I started off like this:
'Handlers for generated form controls Private Sub SaveComment(ByVal sender As Object, ByVal e As EventArgs) Dim rc As New RepairControl rc.SetStatusAndAssignment(lblSelectedSN.Text, lblStatus.Text, txtComments.Text) End Sub
But the txtComments.Text parameter obviously doesn't work because it's created in a programmatic way. As far as this sub is concerned it doesn't exist, but it does at run-time of course. If I use this sub as a handler for the button, sender becomes the button object, but my questions is how do I pass the comments from the text box. I have a feeling it has something to do with E as eventargs. Perhaps I can use the textbox.text as the eventargs parameter?