Marc wrote:
Hi,
I am using the below code to add a button to form. However it is not
working. If I change the form name from 'form1' to 'me' it does add the
button to the current form...any ideas.
You mean you actually changed the form's name to "Me"? Ot did you just
chagne a line like this:
form1.Controls.Add(button1)
to:
Me.Controls.Add(button1)
?
the "Me" keyword refers to the object that the "Me" keyword is used in,
much the same way people use it to refer to themselves when speaking
English. I prefer it over refering to a form by its name within itself.
Also does anyone know a way keep any user generated buttons in the form
even after the application is closed down,..Im guessing this requires a
DB link?
button1.Text = "OK"
' Set the position of the button on the form.
button1.Location = New Point(10, 10)
' Set the text of button2 to "Cancel".
' Add button1 to the form.
form1.Controls.Add(button1)
You probably don't need a database for this. You will probably have to
serialize the object (form), but it's up to you if you want to
serialize it as a file on the local machine where the program is
running, or into a database somewhere. Local is probably much easier.
By the way, I don't know if buttons, textboxes, or other controls are
serializable, I suspect not. I had a similar problem last week. I got
around it by only serializing the most relevant data: the text in the
text boxes, and the text of certain labels.
Search on MSDN for object serializing tutorials for more detailed info.