vb.net - 基于 GridView 创建 Panels
问题描述
我正在制作一个应用程序,其中有必要创建一个包含多个选项的列表,在这种情况下,该列表包括项目的度量及其位置。位置是指在一个面板中,有位置 A、B、C、D,并且每个项目必须占据 GridView 列表中标记的这些位置之一。
应该如下。
我创建了一个代码,但没有与 GridView 连接,并根据在 gridview 中创建的单元数创建对象。
For i = 1 To ContadorIzq
pos = CInt(TextBox38.Text)
poslabel = CInt(TextBox42.Text)
Dim pb As New Panel With
{
.Width = 120,
.Height = 460,
.Top = 10,
.Left = 10,
.BorderStyle = BorderStyle.FixedSingle,
.BackgroundImage = Image.FromFile("C:\Images\sections\Ejem.bmp"),
.BackgroundImageLayout = ImageLayout.Stretch,
.ContextMenuStrip = CntxtMnuStrpUnit,
.Name = "Panel" & CInt(TextBox37.Text),
.Location = New Point(pos, 20)
}
AddHandler pb.Click, AddressOf myClickHandler_b
Dim labela As New Label With {
.AutoSize = True,
.Location = New Point((poslabel), 12),
.Text = "Section " & CInt(TextBox37.Text),
.ForeColor = Color.White,
.BackColor = Color.Transparent,
.Font = New Font(Me.Font, FontStyle.Bold),
.Name = "Label" & CInt(TextBox37.Text)
}
AddHandler labela.Click, AddressOf myClickHandler
labela.Font = New Font(labela.Font, FontStyle.Bold)
Panel1.Controls.Add(pb)
pb.Controls.Add(labela)
Dim posY As Int16 = 30
Dim posX As Int16 = 3
For j = 1 To 4
If j = 1 Then
Dim pbdoors As New Panel With {
.Width = 114,
.Height = 198,
.Top = 10,
.Left = 10,
.BorderStyle = BorderStyle.FixedSingle,
.BackgroundImage = Image.FromFile("C:\Images\Doors\EjemB.bmp"),
.BackgroundImageLayout = ImageLayout.Stretch,
.ContextMenuStrip = CntxtMnuStrpUnit,
.Name = "Panel" & CInt(TextBox37.Text) & j
}
AddHandler pbdoors.Click, AddressOf myClickHandler_doors
pbdoors.Location = New Point(posX, 30)
pb.Controls.Add(pbdoors)
posY = (posY + 100)
ElseIf j = 2 Then
posY = 130
ElseIf j = 3 Then
Dim pbdoors As New Panel With {
.Width = 114,
.Height = 98,
.Top = 10,
.Left = 10,
.BorderStyle = BorderStyle.FixedSingle,
.BackgroundImage = Image.FromFile("C:\Images\Doors\EjemC.bmp"),
.BackgroundImageLayout = ImageLayout.Stretch,
.ContextMenuStrip = CntxtMnuStrpUnit,
.Name = "Panel" & CInt(TextBox37.Text) & j
}
AddHandler pbdoors.Click, AddressOf myClickHandler_doors
pbdoors.Location = New Point(posX, 230)
pb.Controls.Add(pbdoors)
posY = (posY + 100)
ElseIf j = 4 Then
Dim pbdoors As New Panel With {
.Width = 114,
.Height = 98,
.Top = 10,
.Left = 10,
.BorderStyle = BorderStyle.FixedSingle,
.BackgroundImage = Image.FromFile("C:\Images\Doors\EjemC2.bmp"),
.BackgroundImageLayout = ImageLayout.Stretch,
.ContextMenuStrip = CntxtMnuStrpUnit,
.Name = "Panel" & CInt(TextBox37.Text) & j
}
AddHandler pbdoors.Click, AddressOf myClickHandler_doors
pbdoors.Location = New Point(posX, 330)
pb.Controls.Add(pbdoors)
posY = (posY + 100)
End If
Next
TextBox38.Text = pos + 120
TextBox37.Text = CInt(TextBox37.Text) + 1
TextBox40.Text = CInt(TextBox40.Text) + 120
Next
拜托,有什么想法吗?,你能帮帮我吗?
解决方案
推荐阅读
- php - 如何在实时 Firebase 数据库上侦听以通过后端 laravel 和 websocket 动态获取数据,而不使用 javascript
- kotlin - 如何将通用范围的暂停 lambda 传递给 Kotlin 中的类方法?
- python - PurePath.match(pattern) 和 Path.glob(pattern) 之间的差异
- html - 动画父母宽度在孩子 *ngIf
- javascript - 如何检测移动设备
- python - 如何检测每个对象中python,pandas中的值变化
- javascript - 如何通过运算符链将多个值传递给映射运算符?在 NgRx 效应中
- reactjs - 在 SPA 中移动到下一个组件时如何存储上一个组件的状态?
- mysql - 使用 2 Where 子句更新列不同的表
- r - 在 R 中的航班上使用 Mutate 的算术错误?