Foxtable(狐表)用户栏目专家坐堂 → 求帮忙将这个项目改成打开的时候是折叠的状态的代码,谢谢啦


  共有3753人关注过本帖树形打印复制链接

主题:求帮忙将这个项目改成打开的时候是折叠的状态的代码,谢谢啦

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/2/26 15:42:00 [显示全部帖子]

afterLoad事件

 

For i As Integer = 1 To 4
    Dim LblCtl As Windows.Forms.Label = e.Form.Controls("Label" & i).BaseControl
    LblCtl.Image = GetImage("Control-270.png")
    LblCtl.ImageAlign = Drawing.ContentAlignment.MiddleLeft
    LblCtl.Cursor = Windows.Forms.Cursors.Hand
    Dim Pnl As WinForm.Panel = e.Form.Controls("Panel" & i)
    pnl.Visible = False
   
    Dim Lbl As WinForm.Label = e.Form.Controls("Label" & i)
    lbl.Top = (lbl.height+3) * (i-1) + 3
Next


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/7 9:56:00 [显示全部帖子]

Click事件

 

Select Case e.Sender.Name
    Case "Label1","Label2","Label3","Label4"
       
       
        Dim top As Integer = 3
        For i As Integer = 1 To 4
            Dim Lbl As WinForm.Label = e.Form.Controls("Label" & i)
            Dim   Pnl = e.Form.Controls("Panel" & i)
            If i = e.sender.name.Replace("Label", "") Then
                Pnl.Visible = Not Pnl.Visible
                e.sender.BaseControl.Image = IIf(Pnl.Visible, GetImage("control-270.png"),GetImage("control.png"))
                e.sender.BackColor = IIf(Pnl.Visible, Drawing.SystemColors.ControlDark, Drawing.SystemColors.Control)
            Else
                Pnl.Visible = False
            End If
            lbl.Top = Top
            Top += lbl.Height + 3
            If pnl.visible Then
                Pnl.Top = Top
                Top += pnl.height + 3
            End If
        Next
End Select


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/7 10:38:00 [显示全部帖子]

 代码写在一个窗口上肯定比较好,如果要把这个东西做成通用的,那就要把代码移植到内部函数取,这样功能才能被复制。

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/15 22:48:00 [显示全部帖子]

Select Case e.Sender.Name
    Case "Label1","Label2","Label3","Label4"
        Dim top As Integer = 3
        For i As Integer = 1 To 4
            Dim Lbl As WinForm.Label = e.Form.Controls("Label" & i)
            Dim Pnl = e.Form.Controls("Panel" & i)
            If i = e.sender.name.Replace("Label", "") Then
                Pnl.Visible = Not Pnl.Visible
                e.sender.BaseControl.Image = IIf(Pnl.Visible, GetImage("control-270.png"),GetImage("control.png"))
                e.sender.BackColor = IIf(Pnl.Visible, Drawing.SystemColors.ControlDark, Drawing.SystemColors.Control)
            Else
                Pnl.Visible = False
            End If
            lbl.Top = Top
            Top += lbl.Height + 0
            If pnl.visible Then
                Pnl.Top = Top
                Top += pnl.height + 10
            Else
                top += 10
            End If
        Next
End Select


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/16 16:09:00 [显示全部帖子]

1、panel那里,扩展尺寸,不要设置成2800,改成0

 

2、如果有闪动,在click事件加上

 

e.Form.StopRedraw

 

'代码

e.Form.ResumeRedraw


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/16 17:09:00 [显示全部帖子]

Select Case e.Sender.Name
   
    Case "Button1","Button2","Button3","Button4","Button5","Button6","Button7","Button8","Button9"
       
        e.Form.StopRedraw
        Dim p As WinForm.Panel = e.Form.Controls("面板滚动")
        p.AutoScroll = False
        Dim top As Integer = 0
        Dim idx As Integer = e.sender.name.replace("Button", "")
        For i As Integer = 1 To 9
           
            Dim but As winform.button = e.Form.controls("Button" & i)
            Dim   Pnl = e.Form.Controls("Panel" & i)
           
            but.Top = Top
            Top += but.Height + 0 ''10
           
           
            If i = idx Then
                If pnl.visible = False Then
                    Pnl.Top = Top
                    Top += Pnl.height + 0 ''30
                End If
            Else
                Pnl.Visible = False
            End If
           
            Top += 10
           
        Next
       
        e.Form.Controls("Panel" & idx).Visible = Not e.Form.Controls("Panel" & idx).Visible
        p.AutoScroll = True
        'e.Form.Controls("button" & idx).Select
        e.Form.ResumeRedraw
End Select

 回到顶部