This is driving me crazy! It should be so simple! Can anyone tell me
what is going wrong? All I am doing is adding a single button to a
form but it fails :-(
I am using VB.NET 2005 to create an application for Windows Mobile
2005. I have a form and in the Form_Load event I have the following
code:
Call BuildForm()
Me.Show()
Then, in the called sub I have the following:
Private Sub BuildForm()
Dim newButton As New Button
With newButton
.Name = "Switch"
.Anchor = AnchorStyles.Left
.Enabled = True
.Height = 50
.Left = 50
.Parent = Me
.Text = "Switch"
.Visible = True
.Width = 150
End With
Me.Controls.Add(newButton)
End Sub
Which gives me the following error on startup at the line "Dim
newButton As New Button":
System.NotSupportedException was unhandled
Message="NotSupportedException"
StackTrace:
at Microsoft.AGL.Common.MISC.HandleAr()
at System.Windows.Forms.Control._InitInstance()
at System.Windows.Forms.Control..ctor()
at System.Windows.Forms.ButtonBase..ctor()
at System.Windows.Forms.Button..ctor()
at NoData.MainScreen.BuildForm()
at NoData.MainScreen.MainScreen_Load()
at System.Windows.Forms.Form.OnLoad()
at System.Windows.Forms.Form._SetVisibleNotify()
at System.Windows.Forms.Control.set_Visible()
at System.Windows.Forms.Application.Run()
at NoData.MainScreen.Main()
TIA,
Hugh