以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]这段代码不能用在按钮单机事件吗?如果不行,怎么修改一下?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=29051)

--  作者:aduydgd
--  发布时间:2013/2/26 14:26:00
--  [求助]这段代码不能用在按钮单机事件吗?如果不行,怎么修改一下?
\'...
Dim t As Table = CurrentTable
Dim m As RibbonMenu.MenuButton = e.MenuButton
Dim c As Col = t.Cols(t.ColSel)
Dim Less As RibbonMenu.Button = CType(m.Items("Less"), RibbonMenu.Button)
Dim LessOrEqual As RibbonMenu.Button = CType(m.Items("LessOrEqual"), RibbonMenu.Button)
Dim More As RibbonMenu.Button = CType(m.Items("More"), RibbonMenu.Button)
Dim MoreOrEqual As RibbonMenu.Button = CType(m.Items("MoreOrEqual"), RibbonMenu.Button)
Dim Equal As RibbonMenu.Button = CType(m.Items("Equal"), RibbonMenu.Button)
Dim NotEqual As RibbonMenu.Button = CType(m.Items("NotEqual"), RibbonMenu.Button)
Dim SamePeriod As RibbonMenu.MenuButton = CType(m.Items("SamePeriod"), RibbonMenu.MenuButton)
Dim Period As RibbonMenu.MenuButton = CType(m.Items("Period"), RibbonMenu.MenuButton)
Dim Separator As RibbonMenu.Separator = CType(m.Items("Separator"), RibbonMenu.Separator)
Dim StringFilter As RibbonMenu.MenuButton = CType(m.Items("StringFilter"), RibbonMenu.MenuButton)
Dim ValueFilter As RibbonMenu.MenuButton = CType(m.Items("ValueFilter"), RibbonMenu.MenuButton)
Dim FilterTrue As RibbonMenu.Button = CType(m.Items("FilterTrue"), RibbonMenu.Button)
Dim FilterFalse As RibbonMenu.Button = CType(m.Items("FilterFalse"), RibbonMenu.Button)
Dim Null As RibbonMenu.Button = CType(m.Items("Null"), RibbonMenu.Button)
Dim NotNull As RibbonMenu.Button = CType(m.Items("NotNull"), RibbonMenu.Button)
If c.IsDate Then
    ValueFilter.Text= "日期筛选"
ElseIf c.IsNumeric Then
    ValueFilter.Text= "数值筛选"
End If
If t.Position < 0 Then
    FilterTrue.Visible = False
    FilterFalse.Visible = False
    Less.Visible = False
    LessOrEqual.Visible = False
    More.Visible = False
    MoreOrEqual.Visible = False
    Equal.Visible = False
    NotEqual.Visible = False
    SamePeriod.Visible = False
    Separator.Visible = False
    Period.Visible = c.IsDate
    Return
Else
    Period.Visible = c.IsDate
    SamePeriod.Visible = c.IsDate
    Separator.Visible = c.IsDate Or c.IsString Or c.IsNumeric
    StringFilter.Visible = c.IsString
    ValueFilter.Visible = c.IsDate Or c.IsNumeric
    If c.IsDate Then
        SamePeriod.Items("Hour").Visible = (c.DataCol.DateTimeFormat <> DateTimeFormatEnum.Date)
        SamePeriod.Items("Minute").Visible = (c.DataCol.DateTimeFormat <> DateTimeFormatEnum.Date)
    End If
End If
If c.IsBoolean Then
    FilterTrue.Visible = True
    FilterFalse.Visible = True
    Equal.Visible = False
    NotEqual.Visible = False
    Less.Visible = False
    More.Visible = False
    LessOrEqual.Visible = False
    MoreOrEqual.Visible = False
    Null.Visible = False
    NotNull.Visible = FAlse
Else
    FilterTrue.Visible = False
    FilterFalse.Visible = False
    Equal.Visible = True
    NotEqual.Visible = True
    Null.Visible = True
    NotNull.Visible = True
    If t.Current.IsNull(t.ColSel) OrElse c.IsString Then
        Less.Visible = False
        More.Visible = False
        LessOrEqual.Visible = False
        MoreOrEqual.Visible = False
    Else
        Less.Visible = True
        More.Visible = True
        LessOrEqual.Visible = True
        MoreOrEqual.Visible = True
    End If
End If
If t.Current.IsNull(t.ColSel) Then
    Equal.Visible = False
    NotEqual.Visible = False
    m.Items("SamePeriod").Visible = False
ElseIf c.IsString Then
    Dim v As String = t.Text
    If v > "" AndAlso v.Length > 15 then
        v = v.SubString(0,15) & "..."
    End If
    Equal.Text = "等于 """ & v  & """"
    NotEqual.Text = "不等于 """ & v & """"
ElseIf c.IsNumeric Then
    Equal.Text = "等于 " & t.Text
    NotEqual.Text = "不等于 " & t.Text
    Less.Text = "小于 " & t.Text
    LessOrEqual.Text = "不大于 " & t.Text
    More.Text = "大于 " & t.Text
    MoreOrEqual.Text = "不小于 " & t.Text
ElseIf c.IsDate Then
    Equal.Text = "等于 " & t.Text
    NotEqual.Text = "不等于 " & t.Text
    Less.Text = "早于 " & t.Text
    More.Text = "晚于 " & t.Text
    LessOrEqual.Text = "不晚于 " & t.Text
    MoreOrEqual.Text = "不早于 " & t.Text
End If

--  作者:狐狸爸爸
--  发布时间:2013/2/26 14:35:00
--  
这是菜单事件,不是按钮事件,不同的事件,e参数不同,代码通常不能混用。
--  作者:aduydgd
--  发布时间:2013/2/26 14:49:00
--  
这段代码能否改良为按钮事件?
--  作者:狐狸爸爸
--  发布时间:2013/2/26 14:58:00
--  

图片点击可在新窗口打开查看