Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共18 条记录, 每页显示 10 条, 页签: [1] [2]
[浏览完整版]

标题:文本框变色问题

1楼
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

图片点击可在新窗口打开查看此主题相关图片如下:提问图片.jpg
图片点击可在新窗口打开查看
为什么这样我要求的是点击"Label8-1" 后 Label" & i & "_1 全部变色


2楼
有点蓝 发表于:2025/1/3 15:01:00
没看懂什么意思
3楼
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编辑过]
4楼
有点蓝 发表于: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 
5楼
hongye 发表于:2025/1/3 15:42:00
如何知道我有几个 e.Form.Controls("Label" & i & "_1"),,有时 e.Form.Controls("Label" & i & "_1") 的数量是不固定的
6楼
有点蓝 发表于:2025/1/3 15:44:00
设计时考虑把【Label8-1】名称改为【Label8-1-7】,然后通过名称取最后的数字作为数量
7楼
hongye 发表于:2025/1/3 15:46:00
Label8-1是固定的,Label" & i & "_1"是不固定的,但是最多也只是7

也就是图片里的1_1到7_7,不过只有少不会多
[此贴子已经被作者于2025/1/3 15:48:08编辑过]
8楼
hongye 发表于:2025/1/3 17:01:00
如何知道动态增加的Label" & i & "_1的数量有多少
[此贴子已经被作者于2025/1/3 17:02:01编辑过]
9楼
有点蓝 发表于:2025/1/3 17:07:00
怎么【动态增加】的?
10楼
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
共18 条记录, 每页显示 10 条, 页签: [1] [2]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .04883 s, 2 queries.