以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请教如何让按钮显示出来?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=65610)

--  作者:zhy400137
--  发布时间:2015/3/19 9:45:00
--  请教如何让按钮显示出来?
我做了个按钮,更改样式后变成已审核的标记来用,属性设置为不可见,
窗口左边为目录树,在节点点击的按钮处写了
                If ftp1.Download("\\" & FileName,ProjectPath & "FileMange\\" & FileName) = True Then
                    Messagebox.show("下载完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                    e.Form.Controls("WebBrowser1").basecontrol.Navigate(ProjectPath & "FileMange\\" & FileName )
                    If e.Node.DataRow("文件状态") = "已审核"
                        e.Form.Controls("Button1").Visible= True
                    Else
                        e.Form.Controls("Button1").Visible= False
                    End If
                Else
                    Messagebox.show("下载失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                End If

但点击后,按钮不会显示出来,请教老师是什么原因?谢谢

--  作者:Bin
--  发布时间:2015/3/19 9:47:00
--  
If e.Node.DataRow("文件状态") = "已审核"    \'说明没有符合这个条件,符合的话进入IF条件 执行显示代码就会显示了.你调试一下便知  搞不定请上例子
                        e.Form.Controls("Button1").Visible= True  

--  作者:zhy400137
--  发布时间:2015/3/19 9:54:00
--  
单独测试了e.Form.Controls("Button1").Visible= True  ,是能正确显示,但放在下面的代码里,不起作用!

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim FileName As String
Dim FileLen As Integer
Dim UserName As String = user.Name
If e.node.Level = 1 Then \'如果是二级节点
    If e.node.DataRow.Isnull("文件全名") Then
        MessageBox.show("此文件不许任何人查看!","提示")
    ElseIf e.node.DataRow("文件可查看人").IndexOf(UserName) = -1 And (User.Type <> UserTypeEnum.Developer And User.Type <> UserTypeEnum.Administrator) Then
        MessageBox.show("你没有查看此文件的权限!","提示")
        Return
    Else
        If  not e.node.DataRow.Isnull("文件全名") Then
            FileName =e.node.DataRow("文件全名")
            FileLen=FileName.Length-2
            FileName =  FileName.SubString(2,FileLen)
        End If
        If Not FileSys.DirectoryExists(ProjectPath & "\\FileMange") Then
            FileSys.CreateDirectory(ProjectPath & "\\FileMange")
        End If
        If FileSys.FileExists(ProjectPath & "FileMange\\" & FileName) Then
            try
               Dim aa As New System.IO.FileStream(ProjectPath & "FileMange\\" & FileName, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.None)
                aa.Dispose()
                FileSys.DeleteFile(ProjectPath & "FileMange\\" & FileName,2,2) \'则彻底删除之
            Catch ex As Exception
                MessageBox.Show("当前文件已在浏览窗口打开,不能下载同名文件,请先点击下载别的文件后,再打开!","提示",MessageBoxButtons.OK)
            End Try
        End If
        Dim ftp1 As new ftpclient
        ftp1.host="192.168.0.248"
        ftp1.Account = "ytxsp"
        ftp1.password = "ytx820723"
        ftp1.UTF8=True
        If ftp1.Connected = False \'如果FTP没有连接
            If ftp1.Connect Then \'连接FTP
                If ftp1.Download("\\" & FileName,ProjectPath & "FileMange\\" & FileName) = True Then
                    Messagebox.show("下载完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                    e.Form.Controls("WebBrowser1").basecontrol.Navigate(ProjectPath & "FileMange\\" & FileName )
                    If e.Node.DataRow("文件状态") = "已审核"
                        e.Form.Controls("Button1").Visible= True
                    Else
                        e.Form.Controls("Button1").Visible= False
                    End If
                Else
                    Messagebox.show("下载失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                End If
            Else
                Messagebox.show("连接FTP失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            End If
        End If
    End If
End If

--  作者:Bin
--  发布时间:2015/3/19 9:55:00
--  
说明没有进入IF条件.2楼已经解释了.

建议您用这个方法:
http://www.foxtable.com/help/topics/1485.htm

先找出是哪一行出错,然后分析原因,搞不定,可以在论坛发帖,贴出代码,并告诉我们运行到哪一行出错,以及错误提示。

--  作者:zhy400137
--  发布时间:2015/3/19 9:56:00
--  
我左边是个目录树,右边是WebBrowser1控件,感觉是WebBrowser1控件加载后,就变不见了
--  作者:有点甜
--  发布时间:2015/3/19 9:59:00
--  

 加入msgbox测试,看是否运行了对应的代码啊

 

                    If e.Node.DataRow("文件状态") = "已审核"

msgbox(1)

                        e.Form.Controls("Button1").Visible= True
                    Else
msgbox(2)
                        e.Form.Controls("Button1").Visible= False
                    End If

--  作者:zhy400137
--  发布时间:2015/3/19 10:05:00
--  
                    msgbox(e.Node.DataRow("文件状态"))  
                    If e.Node.DataRow("文件状态") = "已审核"
                        e.Form.Controls("Button1").Visible= True
                       msgbox(1)
                    Else
                        e.Form.Controls("Button1").Visible= False
                       msgbox(2)
                    End If

第一名弹出的 明明是已审核
但为什么IF语句会 显示是2呢?

--  作者:有点甜
--  发布时间:2015/3/19 10:07:00
--  

是不是有空格之类的东西啊,试试

 

msgbox("aaa" & e.Node.DataRow("文件状态") & "bbb")  

 


--  作者:Bin
--  发布时间:2015/3/19 10:08:00
--  
有空格可以改为

 If e.Node.DataRow("文件状态").trim() = "已审核"
[此贴子已经被作者于2015/3/19 10:08:24编辑过]

--  作者:zhy400137
--  发布时间:2015/3/19 10:09:00
--  
真是有,但我用的是自定义列表项目,怎么会产生空格呢?我晕!