469,573 Members | 1,667 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,573 developers. It's quick & easy.

Simple form creation problem - CF2005

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

Aug 21 '07 #1
0 997

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by LRW | last post: by
4 posts views Thread by Stuart Perryman | last post: by
reply views Thread by Tal Sharfi | last post: by
2 posts views Thread by Marty | last post: by
30 posts views Thread by galiorenye | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.