D
Dragon
Hi,
I am trying to create a form and add some controls to it programmatically. I
am pasting the code I have so far, below. here are the issues I am having.
#1. I am having to subtract additional 35 points from the
closeAbuotButton.Top ot the control goes out of form's bounds. I have no
clue why.
#2. I do not know how to access my Close Button's click event. It is asking
me to create "WithEvents" but I can't figure our where/how to use it.
Thank you.
'Code still not working...
Private Sub aboutHelpMenuItem_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles aboutHelpMenuItem.Click
'Create and Display About Dialog.
Dim nameLabel As New Label
Dim messageLabel As New Label
aboutForm = New Form
'Create Form
With aboutForm
.Text = "About"
.FormBorderStyle = FormBorderStyle.FixedDialog
.Height = 150
.Width = 300
'.ControlBox = False
End With
'Add Message Label
aboutForm.Controls.Add(messageLabel)
With messageLabel
.Text = "Programmed by Me"
.Top = 5
.Left = 5
.Width = aboutForm.Width - 5
.Height = 20
.TextAlign = ContentAlignment.MiddleCenter
End With
'Add Close Button
aboutForm.Controls.Add(closeAboutButton)
With closeAboutButton
.Hide()
.Text = "&Close"
.Width = 100
.Height = 25
.Top = aboutForm.Height - closeAboutButton.Height - 35 'For some reason
if I do not have -35, control goes out of form's bounds.
.Left = (aboutForm.Width / 2) - (closeAboutButton.Width / 2)
.Show()
End With
aboutForm.ShowDialog()
End Sub
Private Sub closeAboutButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles closeAboutButton.Click
'Close Form
Me.Close()
End Sub
I am trying to create a form and add some controls to it programmatically. I
am pasting the code I have so far, below. here are the issues I am having.
#1. I am having to subtract additional 35 points from the
closeAbuotButton.Top ot the control goes out of form's bounds. I have no
clue why.
#2. I do not know how to access my Close Button's click event. It is asking
me to create "WithEvents" but I can't figure our where/how to use it.
Thank you.
'Code still not working...
Private Sub aboutHelpMenuItem_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles aboutHelpMenuItem.Click
'Create and Display About Dialog.
Dim nameLabel As New Label
Dim messageLabel As New Label
aboutForm = New Form
'Create Form
With aboutForm
.Text = "About"
.FormBorderStyle = FormBorderStyle.FixedDialog
.Height = 150
.Width = 300
'.ControlBox = False
End With
'Add Message Label
aboutForm.Controls.Add(messageLabel)
With messageLabel
.Text = "Programmed by Me"
.Top = 5
.Left = 5
.Width = aboutForm.Width - 5
.Height = 20
.TextAlign = ContentAlignment.MiddleCenter
End With
'Add Close Button
aboutForm.Controls.Add(closeAboutButton)
With closeAboutButton
.Hide()
.Text = "&Close"
.Width = 100
.Height = 25
.Top = aboutForm.Height - closeAboutButton.Height - 35 'For some reason
if I do not have -35, control goes out of form's bounds.
.Left = (aboutForm.Width / 2) - (closeAboutButton.Width / 2)
.Show()
End With
aboutForm.ShowDialog()
End Sub
Private Sub closeAboutButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles closeAboutButton.Click
'Close Form
Me.Close()
End Sub