471,851 Members | 1,236 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,851 software developers and data experts.

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 1025

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 YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.