C
Cashewz
Hello, i'm trying to set this code:
rtbRichTextBox.SaveFile(Me.Text & ".rtf")
to the code below in a click event for "btnButton". The button was
created at runtime, so i'm not sure how to set up the click event for a
control that doesnt exist at design time.
Private Sub mnuNewMemo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuNewMemo.Click
Dim MyChild As New Form
MyChild.MdiParent = Me
MyChild.Show()
Static intNum As Integer
intNum += 1
MyChild.Text = "Child Form "
MyChild.Text &= intNum
MyChild.Height = 400
MyChild.Width = 400
''' CONTROLS CREATED AT RUNTIME!
'Declare Controls
Dim rtbRichTextBox As System.Windows.Forms.RichTextBox
Dim btnButton As System.Windows.Forms.Button
'Instantiate the Controls
rtbRichTextBox = New System.Windows.Forms.RichTextBox
btnButton = New System.Windows.Forms.Button
'Add the controls to the form
MyChild.Controls.Add(rtbRichTextBox)
rtbRichTextBox.Dock = DockStyle.Fill
rtbRichTextBox.Controls.Add(btnButton)
btnButton.Left = rtbRichTextBox.Width - 125
btnButton.Top = 25
btnButton.Width = 75
btnButton.Height = 20
btnButton.Text = "Save"
End Sub
rtbRichTextBox.SaveFile(Me.Text & ".rtf")
to the code below in a click event for "btnButton". The button was
created at runtime, so i'm not sure how to set up the click event for a
control that doesnt exist at design time.
Private Sub mnuNewMemo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuNewMemo.Click
Dim MyChild As New Form
MyChild.MdiParent = Me
MyChild.Show()
Static intNum As Integer
intNum += 1
MyChild.Text = "Child Form "
MyChild.Text &= intNum
MyChild.Height = 400
MyChild.Width = 400
''' CONTROLS CREATED AT RUNTIME!
'Declare Controls
Dim rtbRichTextBox As System.Windows.Forms.RichTextBox
Dim btnButton As System.Windows.Forms.Button
'Instantiate the Controls
rtbRichTextBox = New System.Windows.Forms.RichTextBox
btnButton = New System.Windows.Forms.Button
'Add the controls to the form
MyChild.Controls.Add(rtbRichTextBox)
rtbRichTextBox.Dock = DockStyle.Fill
rtbRichTextBox.Controls.Add(btnButton)
btnButton.Left = rtbRichTextBox.Width - 125
btnButton.Top = 25
btnButton.Width = 75
btnButton.Height = 20
btnButton.Text = "Save"
End Sub