rufus Posted July 16, 2003 Posted July 16, 2003 can we create during runtime, like can I write code, that creates controls like textbox, buttons, and display on the outout. without creating the controls, using the IDE. Quote Rufus
bungpeng Posted July 16, 2003 Posted July 16, 2003 Just wonder why don't you write your controls first, then decide whether deploy it during run time. I don't think there is a way for you to CREATE control during run time. Maybe I misunderstanding you, what do you want to do actually? Quote
rufus Posted July 16, 2003 Author Posted July 16, 2003 Actually, Iam developing a game, Iam using threading concept to display some balls going around the screen randomly. I displayed a gun image on the screen too. Now want to shoot those balls by moving the mouse on the screen. so for this I need to move the picturebox, which I have already created. so I tried to create picture boxes during runtime, when ever I press the mouse button down and set the location of the picture box to the mouse positions. so thats why I need to create the picturebox control during runtime and assign the location. so I wrote the following, but could not display anything. Is the below way correct or is there any other way. Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown Dim pic As New System.Windows.Forms.PictureBox() Dim resources As System.Resources.ResourceManager = new System.Resources.ResourceManager(GetType(Form1)) pic.Location = New System.Drawing.Point(e.X, e.Y) pic.Size = New System.Drawing.Size(104, 80) pic.Image = CType(resources.GetObject("j:\shooter.jpg"),_ System.Drawing.Bitmap) pic.Visible = True End Sub Quote Rufus
*Experts* mutant Posted July 16, 2003 *Experts* Posted July 16, 2003 You need to add it to the control collection of your form: Me.Controls.Add(pic) By the way, dont post Control questions in Database forum :). Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.