| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 460 人关注过本帖
标题:有鬼的控件数组?!
只看楼主 加入收藏
xin9chen007
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-9-7
收藏
 问题点数:0 回复次数:0 
有鬼的控件数组?!
我建了一个label的控件数组,从上到下依次排列。想实现以下效果:
1,单击其中任意一个控件时,被单击者,背景变红色:另外两个背景透明
2,鼠标滑到任意一个控件上时,该控件背景变黄色(背景为红色者,除外) ;其余背景透明(背景为红色者,除外)。
3,鼠标滑到窗体上时,所有控件背景透明(背景为红色者,除外)。
为此,我写了以下程序:
   PART01:    Private Sub Label1_Click(Index As Integer)
   Select Case Index
       Case 0
            For Index = 0 To 2
                If Label1(Index).BackColor = &H8080FF Then
                   Label1(Index).BackStyle = 0
                End If
            Next Index
            Label1(0).BackStyle = 1
            Label1(0).BackColor = &H8080FF
        Case 1
            For Index = 0 To 2
                If Label1(Index).BackColor = &H8080FF Then
                   Label1(Index).BackStyle = 0
                End If
            Next Index
            Label1(1).BackStyle = 1
            Label1(1).BackColor = &H8080FF
          Case 2
            For Index = 0 To 2
                If Label1(Index).BackColor = &H8080FF Then
                   Label1(Index).BackStyle = 0
                End If
            Next Index
             Label1(2).BackStyle = 1
             Label1(2).BackColor = &H8080FF
           
    End Select
   
   
   
End Sub

PART02:         Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
   Select Case Index
      Case 0
          If Label1(0).BackColor = &H8080FF Then
          Else
                   For Index = 0 To 2
                     If Label1(Index).BackColor = &HC0FFFF Then
                        Label1(Index).BackStyle = 0
                     End If
                   Next Index
                   Label1(0).BackStyle = 1
                   Label1(0).BackColor = &HC0FFFF
               
           End If
      Case 1
          If Label1(1).BackColor = &H8080FF Then
         
         
          Else
            For Index = 0 To 2
                    If Label1(Index).BackColor = &HC0FFFF Then
                       Label1(Index).BackStyle = 0
                    End If
            Next Index
            Label1(1).BackColor = &HC0FFFF
            Label1(1).BackStyle = 1
           End If
       Case 2
          If Label1(2).BackColor = &H8080FF Then
          Else
                  For Index = 0 To 2
                    If Label1(Index).BackColor = &HC0FFFF Then
                       Label1(Index).BackStyle = 0
                    End If
                   Next Index
                   Label1(2).BackStyle = 1
                   Label1(2).BackColor = &HC0FFFF
               
           End If
     
  End Select
  
     
     
End Sub

PART03:     Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  For Index = 0 To 2
      If Label1(Index).BackColor = &H8080FF Then
      Else
         Label1(Index).BackStyle = 0
      End If
  Next Index
End Sub

单独用PART01,可以实现单击效果
单独用PART02和PART03,可以实现滑动效果
可是,当三部分同时使用时,单击数次后,滑动效果就消失

why?
搜索更多相关主题的帖子: 控件数组 label_mousemove 
2008-09-27 13:43
快速回复:有鬼的控件数组?!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042996 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved