Dim lb8 As WinForm.Label = e.Form.Controls("Label8-1")
If lb8.text <> "" Then
Dim i As Integer
For i = 1 To 7
If lb8.BackColor = Color.DimGray Then
If e.Form.Controls("Label" & i & "_1").BackColor = Color.DarkGray Then
e.Form.Controls("Label" & i & "_1").BackColor = Color.White
e.Form.Controls("Label" & i & "_1").ForeColor = Color.Black
End If
lb8.ForeColor = Color.Black
lb8.BackColor = Color.Transparent
ElseIf lb8.BackColor = Color.Transparent Then
If e.Form.Controls("Label" & i & "_1").BackColor = Color.White Then
e.Form.Controls("Label" & i & "_1").BackColor = Color.DarkGray
e.Form.Controls("Label" & i & "_1").ForeColor = Color.DimGray
End If
lb8.ForeColor = Color.DarkGray
lb8.BackColor = Color.DimGray
End If
Next
End If
此主题相关图片如下:提问图片.jpg
为什么这样我要求的是点击"Label8-1" 后 Label" & i & "_1 全部变色
当按下
Label8-1后,Label8-1变色,所在的行 Label" & i & "_1变色
也就是当你按下Label8-1后,如果Label8-1的底色是透明色,那么Label8-1底色变成深灰色,字体变成浅灰色,而Label" & i & "_1不管之前是什么颜色,都会底色变成浅灰色,字体变成深灰色,反之那么Label8-1底色变成透明色,字体变成黑色,而Label" & i & "_1不管之前是什么颜色,都会底色变成白色,字体变成黑色
[此贴子已经被作者于2025/1/3 15:11:08编辑过]
如何知道我有几个 e.Form.Controls("Label" & i & "_1"),,有时 e.Form.Controls("Label" & i & "_1") 的数量是不固定的
Label8-1是固定的,Label" & i & "_1"是不固定的,但是最多也只是7
也就是图片里的1_1到7_7,不过只有少不会多
[此贴子已经被作者于2025/1/3 15:48:08编辑过]
如何知道动态增加的
Label" & i & "_1的数量有多少
[此贴子已经被作者于2025/1/3 17:02:01编辑过]
For j As Integer = 1 To 7
For i As Integer = 1 To 7
' Dim dr As String = e.Form.Controls("Ts_" & i & "_" & j).text
' Dim dr2 As String = e.Form.Controls("Tg_" & j).text
' Dim dr3 As String = e.Form.Controls("Tsy_" & i).text
' If dr <> "" And dr2 <> "" And dr3 <> "" Then
Dim lbl As WinForm.Label
lbl = Forms("数量选择").CreateControl("Label" & i & "_" & j, ControlTypeEnum.Label)
lbl.Height = 25
lbl.Width = 58
lbl.Left = 88 + 58 * (i - 1) - (i - 1)
lbl.Top = 96 + 25 * (j - 1) - (j - 1)
lbl.AutoSize = False
lbl.BorderColor = Color.Black
lbl.BackColor = Color.White
lbl.Font = New Font("Arial Narrow", 9)
lbl.BorderStyle = BorderStyle.FixedSingle
lbl.TextAlign = ContentAlignment.MiddleCenter
Forms("数量选择").AddControl(lbl)
' lbl.Text = i & "_" & j
' lbl.Text = e.Form.Controls("Tsy_" & i).Value
' lbl.Text = e.Form.Controls("Tg_" & j).Value
' lbl.Text = e.Form.Controls("Ts_" & i & "_" & j).Value
' End If
Next
Next