Visual Basic - como crear 40 picturebox y limpiar picturebox en tiempo deejecucion en vb.net

Life is soft - evento anual de software empresarial
 
Vista:
Imágen de perfil de ros anhu apellido

como crear 40 picturebox y limpiar picturebox en tiempo deejecucion en vb.net

Publicado por ros anhu apellido (5 intervenciones) el 28/08/2021 23:11:05
como crear 40 imagenes en tiempo de ejecucion y poder limpiarlas en vb.net2019

* creamos un panel pn para alli ponerls img
declaramos pb a nivel de formulario para q pieda ser agarrados desde otro evento
Dim pb As PictureBox
Sub crear_picturesBox_()
For i As Integer = 0 To 40 - 1

'Dim pb As New PictureBox
pb = New PictureBox
pb.Size = New Size(50, 60)
'pb.Location = New Point(10, 10)''original

'pb.SetBounds(10 * i, 10 * i, 40, 50)
pb.BringToFront()
pb.Name = "Carta" & i.ToString
pb.Tag = i ''para poder identificarlo con tag
'Me.Controls.Add(pb) ''agregamos al frm
pn.Controls.Add(pb)
'pb.Image = My.Resources.b1
'pb.Image = My.Resources._20507187_10154875904033177_3442867215593708903_o
pb.Image = My.Resources.interogacion

pb.BorderStyle = BorderStyle.None
'pb.SizeMode = PictureBoxSizeMode.AutoSize
pb.SizeMode = PictureBoxSizeMode.StretchImage
pb.Cursor = Cursors.Hand
''inicimos las variables x y y
'x_ = 10 : y_ = 10 ''valores iniciales para el primer cuadro

'Select Case i
' 'Case 1 : pb.Location = New Point(10, 10)
' Case 1 : pb.Location = New Point(x_, y_)
' 'diferencia 56
' Case 2 'To 10
' 'pb.Location = New Point(66, 10)
' ' 50+10+6
' 'pb.Location = New Point(pb.Width + 16, 10)
' pb.Location = New Point(10 + (pb.Width * 1) + 6, 10)
' Case 3
' 'pb.Location = New Point(122, 10)
' ' 50+20+6
' 'pb.Location = New Point(pb.Width + 72, 10)
' pb.Location = New Point(10 + pb.Width * 2 + 12, 10)
' Case 4
' 'pb.Location = New Point(178, 10)
' ' 50+20+6
' 'pb.Location = New Point(pb.Width + 128, 10)
' pb.Location = New Point(10 + pb.Width * 3 + 18, 10)
' Case 5
' pb.Location = New Point(10 + pb.Width * 4 + 24, 10)

' ''Case 11 : pb.Location = New Point(10, 76)
' 'Case 12 To 20 : pb.Location = New Point(10, 76 * i)
' 'Case 11 : Exit Sub
'End Select
''solucionado
'Dim j As Integer
'Select Case i
' 'Case 0 : pb.Location = New Point(10, 10)''inicia en 10,10
' Case 0 To 9 '
' ''pero para q funcione asi, debe de estar en indice cero y no en uno
' '' 10 q es fijo + 50 ancho pb * i q es del (0 to 9); 10 de top
' pb.Location = New Point(10 + (pb.Width * i) + 6 * i, 10) ''la primera fila
' Case 10 To 19 '
' j = i - 10 '' q reicicie desde cero el i
' 'pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + 60 + 6)
' pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + pb.Height + 6)
' Case 20 To 29
' j = i - 20 '' q reicicie desde cero

' pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + pb.Height * 2 + 6 * 2)
' Case 30 To 39
' j = i - 30 '' q reicicie desde cero
' pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + pb.Height * 3 + 6 * 3)
'End Select
''solucionado..modelode casino de naipes en losicturebox
'Dim j As Integer
'Select Case i
' 'Case 0 : pb.Location = New Point(10, 10)''inicia en 10,10
' Case 0 To 7 '
' ''pero para q funcione asi, debe de estar en indice cero y no en uno
' '' 10 q es fijo + 50 ancho pb * i q es del (0 to 9); 10 de top
' pb.Location = New Point(10 + (pb.Width * i) + 6 * i, 10) ''la primera fila
' Case 8 To 15 '
' j = i - 10 '' q reicicie desde cero el i
' 'pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + 60 + 6)
' pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + pb.Height + 6)
' Case 16 To 23
' j = i - 20 '' q reicicie desde cero

' pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + pb.Height * 2 + 6 * 2)
' Case 24 To 31
' j = i - 30 '' q reicicie desde cero
' pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + pb.Height * 3 + 6 * 3)
'End Select
''solucion para crear40 picturebox de 8 columnas x5 de fila
Dim j As Integer
Select Case i
'Case 0 : pb.Location = New Point(10, 10)''inicia en 10,10
Case 0 To 7 '
''pero para q funcione asi, debe de estar en indice cero y no en uno
'' 10 q es fijo + 50 ancho pb * i q es del (0 to 9); 10 de top
pb.Location = New Point(10 + (pb.Width * i) + 6 * i, 10) ''la primera fila
Case 8 To 15 '
j = i - 8 '' q reicicie desde cero el i
'pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + 60 + 6)
pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + pb.Height + 6)
Case 16 To 23
j = i - 16 '' q reicicie desde cero
pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + pb.Height * 2 + 6 * 2)
Case 24 To 31
j = i - 24 '' q reicicie desde cero
pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + pb.Height * 3 + 6 * 3)
Case 32 To 39
j = i - 32 '' q reicicie desde cero
pb.Location = New Point(10 + (pb.Width * j) + 6 * j, 10 + pb.Height * 4 + 6 * 4)
End Select
'ListBox1.Items.Add(pb.Name)

AddHandler pb.MouseUp, AddressOf PictureBox1_MouseUp
AddHandler pb.MouseDown, AddressOf PictureBox1_MouseDown
AddHandler pb.MouseMove, AddressOf PictureBox1_MouseMove
Next

End Sub

Sub LimpiarPicturebox(p As Object)
For Each c In p.Controls
If TypeOf (c) Is GroupBox Then
LimpiarPicturebox(c)
ElseIf TypeOf (c) Is PictureBox Then
CType(c, PictureBox).Image = My.Resources.integorante_cuadro
CType(c, PictureBox).BorderStyle = BorderStyle.FixedSingle
End If

Next

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
pn.Size = New Size(466, 342)
Call crear_picturesBox_()
crear_picturesBox_pantilla()

'Call crear_chk()
Call crear_pic_en_tablaLayot_panel()

End Sub

Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
StartPoint = DirectCast(sender, PictureBox).PointToScreen(New Point(e.X, e.Y))
IsDragging = True
'PropertyGrid1.SelectedObject(pb)''sale error

End Sub

Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If IsDragging Then
Dim pb As PictureBox = DirectCast(sender, PictureBox)
Dim EndPoint As Point = pb.PointToScreen(New Point(e.X, e.Y))
pb.Left += (EndPoint.X - StartPoint.X)
pb.Top += (EndPoint.Y - StartPoint.Y)
StartPoint = EndPoint
End If
End Sub

Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
IsDragging = False
End Sub

Private Sub butNuevo_Click(sender As Object, e As EventArgs) Handles butNuevo.Click
Call ocultar()
'Call LimpiarPicturebox(pn)

End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 145
Ha aumentado 1 puesto en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

como crear 40 picturebox y limpiar picturebox en tiempo deejecucion en vb.net

Publicado por Sah1d Ra (191 intervenciones) el 30/08/2021 18:57:45
Espero te pueda servir


En un form crea un PictureBox (Picture1) y agregale a la propiedad index el valor de 0 (cero)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Dim Maximo As Integer
 
Private Sub Form_Load()
 Dim Tempo As Integer
 Maximo = 40
 Do While True
  Tempo = Picture1.Count
  Load Picture1(Tempo)
  Picture1(Tempo).Visible = True
  'Picture1(Tempo).Picture = LoadPicture("...")
  'Mas instruccioes
  If Tempo = Maximo - 1 Then Exit Do
 Loop
End Sub
 
Private Sub Form_Unload(Cancel As Integer)
 Dim Tempo as Integer
 For Tempo = Maximo - 1 to 1 Step -1
  Picture1(Tempo).Cls
  Unload Picture1(Tempo)
 next Tempo
End Sub
 
Private Sub Picture1_Click(Index as Integer)
 Mgsbox "Doble clic a la imagen #" + Cstr(Index)
End Sub

saludos y felices líneas de programaci10n.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 355
Bronce
Ha mantenido su posición en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

como crear 40 picturebox y limpiar picturebox en tiempo deejecucion en vb.net

Publicado por raul (160 intervenciones) el 07/09/2021 19:23:45
Ros ¿no sé que estas intentando hacer? SAH te ha dado una variante...

Pero si lo que intentas hacer es un albun, hermano un listview te seria más comodo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de ros

como crear 40 picturebox y limpiar picturebox en tiempo deejecucion en vb.net

Publicado por ros (5 intervenciones) el 11/09/2021 06:28:31
gracias hermano... ya encontre un metodo y funciona bien.. mira este video
https://www.youtube.com/watch?v=TUtLY4WoMM0


gracias por la ayuda.... ya encontre la formula...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar