以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 文本框变色问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=194666) |
-- 作者:hongye -- 发布时间:2025/1/3 14:56:00 -- 文本框变色问题 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 为什么这样我要求的是点击"Label8-1" 后 Label" & i & "_1 全部变色 |
-- 作者:有点蓝 -- 发布时间:2025/1/3 15:01:00 -- 没看懂什么意思 |
-- 作者:hongye -- 发布时间:2025/1/3 15:04:00 -- 当按下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编辑过]
|
-- 作者:有点蓝 -- 发布时间:2025/1/3 15:35:00 -- Dim lb8 As WinForm.Label = e.Form.Controls("Label8-1") If lb8.text <> "" Then Dim i As Integer If lb8.BackColor = Color.DimGray Then lb8.ForeColor = Color.Black lb8.BackColor = Color.Transparent For i = 1 To 7 e.Form.Controls("Label" & i & "_1").BackColor = Color.White e.Form.Controls("Label" & i & "_1").ForeColor = Color.Black Next ElseIf lb8.BackColor = Color.Transparent Then lb8.ForeColor = Color.DarkGray lb8.BackColor = Color.DimGray For i = 1 To 7 e.Form.Controls("Label" & i & "_1").BackColor = Color.DarkGray e.Form.Controls("Label" & i & "_1").ForeColor = Color.DimGray Next End If End If |
-- 作者:hongye -- 发布时间:2025/1/3 15:42:00 -- 如何知道我有几个 e.Form.Controls("Label" & i & "_1"),,有时 e.Form.Controls("Label" & i & "_1") 的数量是不固定的 |
-- 作者:有点蓝 -- 发布时间:2025/1/3 15:44:00 -- 设计时考虑把【Label8-1】名称改为【Label8-1-7】,然后通过名称取最后的数字作为数量 |
-- 作者:hongye -- 发布时间:2025/1/3 15:46:00 -- Label8-1是固定的,Label" & i & "_1"是不固定的,但是最多也只是7 也就是图片里的1_1到7_7,不过只有少不会多
[此贴子已经被作者于2025/1/3 15:48:08编辑过]
|
-- 作者:hongye -- 发布时间:2025/1/3 17:01:00 -- 如何知道动态增加的Label" & i & "_1的数量有多少 [此贴子已经被作者于2025/1/3 17:02:01编辑过]
|
-- 作者:有点蓝 -- 发布时间:2025/1/3 17:07:00 -- 怎么【动态增加】的? |
-- 作者:hongye -- 发布时间:2025/1/3 17:08:00 -- 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
|