yogi_bear_79
Member
- Joined
- Sep 30, 2009
- Messages
- 19
- Programming Experience
- Beginner
I have a panel with 5 labels and 5 listviews in it. By default they are hidden. At runtime I want only the ones shown that are needed. For example, if there are enough players for three tables then three tables should show up. I know how to make the controls visible, but not sure how to control how many are actually displayed. I also think I may have to do seperate loops and seperate the control types?
I could do it with a big select statment, but it seems kind of messy
VB.NET:
Private Sub Set_Tables()
Dim tables As Long
tables = Math.Ceiling(NumPlayers / NumPerTable)
For x = 1 To tables
For Each ctrl As Control In panelTables.Controls
Dim lv As ListView = CType(ctrl, ListView)
lv.Visible = True
Next
Next
End Sub
I could do it with a big select statment, but it seems kind of messy
VB.NET:
Select Case Math.Ceiling(NumPlayers / NumPerTable)
Case 1
lblTbl1.Visible = True
listViewTbl1.Visible = True
Case 2
lblTbl1.Visible = True
listViewTbl1.Visible = True
lblTbl2.Visible = True
listViewTbl2.Visible = True
Case 3
lblTbl1.Visible = True
listViewTbl1.Visible = True
lblTbl2.Visible = True
listViewTbl2.Visible = True
lblTbl3.Visible = True
listViewTbl3.Visible = True
Case 4
lblTbl1.Visible = True
listViewTbl1.Visible = True
lblTbl2.Visible = True
listViewTbl2.Visible = True
lblTbl3.Visible = True
listViewTbl3.Visible = True
lblTbl4.Visible = True
listViewTbl4.Visible = True
Case 5
lblTbl1.Visible = True
listViewTbl1.Visible = True
lblTbl2.Visible = True
listViewTbl2.Visible = True
lblTbl3.Visible = True
listViewTbl3.Visible = True
lblTbl4.Visible = True
listViewTbl4.Visible = True
lblTbl5.Visible = True
listViewTbl5.Visible = True
Case Else
End Select
Last edited: