以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  用按钮如何实现代码?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=121239)

--  作者:sunion
--  发布时间:2018/7/2 13:46:00
--  用按钮如何实现代码?

DataColChanged事件中的代码,如果要用按钮实现,如何改写呢

If
 e.DataCol.Name = "品名" Then \'如果内容发生变动的是品名列
    If e.NewValue Is Nothing Then \'如果新值是空白,也就是品名列的内容为空
        e.
DataRow("单价") = Nothing \'那么清空此行单价列的内容
    
Else
        Dim
 dr As DataRow
        
\'否则在产品表查找同名的产品行,将找到的行赋值给变量dr
        dr = 
DataTables("产品").Find("[品名] = \'" & e.NewValue & "\'")
        If
 dr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing
            e.
DataRow("单价") = dr("单价"
        End
 If
    End
 If
End
 If

--  作者:y2287958
--  发布时间:2018/7/2 14:04:00
--  
Dim r As Row = CurrentTable.Current
If r IsNot Nothing
    If r.IsNull("品名")
        r("单价") = Nothing
    Else
        Dim dr As DataRow
        dr = DataTables("产品").Find("[品名] = \'" & r("品名") & "\'")
        If dr IsNot Nothing
            r("单价") = dr("单价")
        End If
    End If
End If