Jump to content

[vb.net 2005] adicionar imagem


Cybernavigator

Recommended Posts

Boas

Dim pict As New PictureBox
pict.Name = "Fotografias"
pict.Location = New Point(0, 0)
pict.Size = New Drawing.Size(500, 500)
pict.Image = Image.FromFile("c:\aa.jpg")
Me.Controls.Add(pict)

para lhe  dar-lhe uma acção quando alguém clica-se nela usa o AddHandler Statement

http://msdn2.microsoft.com/en-us/library/7taxzxka(VS.80).aspx

"The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod

Link to comment
Share on other sites

Pessoal, alguém me pode ajudar com isto?

:wallbash:

quero fazer um loop k crie e adicione uma imagem automaticamente ah form...

mas não tou a conseguir.

Tou a usar o seguinte código

    Dim pict() As PictureBox

    Private Sub imagens_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Integer
        Dim xpoint As Integer, ypoint As Integer
        Dim j As Integer = 1
        xpoint = 0
        ypoint = 0
        For i = 1 To 15
            Dim pict(i) As PictureBox
            pict(i).Name() = "Coisa" & i
            pict(i).SizeMode() = PictureBoxSizeMode.AutoSize
            If j = 1 Then
                Label1.Text = pict(i).Location.X
                Label2.Text = pict(i).Location.Y
            ElseIf j = 5 Then
                ypoint = Label2.Text + 34
                j = 1
            End If
            pict(i).Location = New Point(xpoint, ypoint)
            pict(i).Image = Image.FromFile("images\coisa (" & i & ").png")
            Me.Controls.Add(pict(i))
            xpoint += 34
        Next

deixo aki o projecto para terem noçao do erro k obtenho quando o executo.

http://buahaha.no.sapo.pt/imagens.rar

*editado*

Não anda aí nenhuma alma santa que me ajude com isto?

é que encrava logo aki

pict(i).Name() = "Coisa" & i

Melhores cumprimentos,João Lopes***Esta mensagem foi escrita ao abrigo do novo Acordo Ortográfico***

Link to comment
Share on other sites

Boas

Vb.net não suporta arrays de controlos.

Public Class imagens

    Private Sub imagens_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Integer
        Dim xpoint As Integer, ypoint As Integer
        Dim j As Integer = 1
        xpoint = 0
        ypoint = 0
        For i = 1 To 15
            Dim pict As New PictureBox
            pict.Name() = "Coisa" & i
            pict.SizeMode() = PictureBoxSizeMode.AutoSize
            If j = 1 Then
                Label1.Text = pict.Location.X
                Label2.Text = pict.Location.Y
            ElseIf j = 5 Then
                ypoint = Label2.Text + 34
                j = 1
            End If
            pict.Location = New Point(xpoint, ypoint)
            pict.Image = Image.FromFile("images\coisa (" & i & ").png")
            Me.Controls.Add(pict)
            xpoint += 34
        Next
    End Sub

"The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.