2014-04-05 5 views
0

vb 2010의 여러 행에 그림 상자를 만드는 방법을 모르겠습니다. 지금은 에 한 행과 그림 상자 만 만들 수 있습니다. 두 번째 행. 나는 다음과 코드를 사용했다 (결국 나는 각 행에 10 pictureboxes과 5 행에 추가하고 싶습니다) :vb 2010의 행에 그림 상자를 추가하는 방법

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 

Dim xPosition As Integer = 20 
Dim yPosition As Integer = 40 


For i As Integer = 1 To 20 
Dim pb As New PictureBox 

With pb 

If i < 20 Then 
.Name = "PictureBox" & i.ToString 
.SizeMode = PictureBoxSizeMode.Zoom 
.Size = New Size(60, 60) 
.Location = New Point(xPosition, yPosition) 
.Image = My.Resources.Seating_No_Person 

Me.Controls.Add(pb) 

AddHandler pb.Click, AddressOf PictureBox_Click 
xPosition += 70 

ElseIf i > 10 Then 
.Name = "PictureBox" & i.ToString 
.SizeMode = PictureBoxSizeMode.Zoom 
.Size = New Size(60, 60) 
.Location = New Point(20, 120) 
.Image = My.Resources.Seating_No_Person 

Me.Controls.Add(pb) 
AddHandler pb.Click, AddressOf PictureBox_Click 

xPosition += 70 
End If 

Dim thisSeating As New Seating 

With thisSeating 
.SeatNumber = i 
.PB = pb 
.Occupied = False 
End With 

seatingList.Add(thisSeating) 
End With 
Next 

End Sub 

하는 사람이 나를 도와하거나 올바른 경로로 저를 지시 할 의향이있는 경우를 나는 것 매우 고맙습니다 :) 미리 감사드립니다.

+0

y 위치를 늘리시겠습니까? –

+0

두 번째 행에서 새로운 y 위치는 120이지만 그 행에 10이 아닌 새로운 그림 상자가 하나만 나타납니다 – user3501048

답변

0

이게 당신이 찾고 있는게 뭡니까?

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 
    Dim xPosition As Integer = 20 
    Dim yPosition As Integer = 40 

    For i As Integer = 1 To 5 
     For j As Integer = 1 To 10 
      Dim pb As New PictureBox 

      With pb 
       .Name = "PictureBox" & i.ToString 
       .SizeMode = PictureBoxSizeMode.Zoom 
       .Size = New Size(60, 60) 
       .Location = New Point(xPosition + (j * 70), yPosition + (i * 100)) 
       .Image = My.Resources.Seating_No_Person 

       Me.Controls.Add(pb) 

       AddHandler pb.Click, AddressOf PictureBox_Click 

       Dim thisSeating As New Seating 

       With thisSeating 
        .SeatNumber = i 
        .PB = pb 
        .Occupied = False 
       End With 

       seatingList.Add(thisSeating) 
      End With 
     Next 
    Next 
End Sub 
+0

예 soooooo 감사합니다. :) 이제는 내가해야 할 일을 이해합니다 - 이것이 의미가 있습니다 – user3501048

+0

기꺼이 도와 드리겠습니다. . –

관련 문제