Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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.
Rufus
Posted

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?

Posted

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

Rufus
  • *Experts*
Posted

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 :).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...