以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  多列值输入问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=102663)

--  作者:有点蓝
--  发布时间:2017/6/23 15:47:00
--  

Select Case e.DataCol.Name
    Case "第一列"
        If e.NewValue > "" AndAlso (e.DataRow.Isnull("第二列") = False OrElse e.DataRow.Isnull("第三列") = False)  Then
            msgbox("第二列或第三列已经有值")
            e.Cancel = True
        End If
    Case "第二列"
        If e.NewValue > "" AndAlso (e.DataRow.Isnull("第一列") = False OrElse e.DataRow.Isnull("第三列") = False)  Then
            msgbox("第一列第三列已经有值")
            e.Cancel = True
        End If
    Case "第三列"
        If e.NewValue > "" AndAlso (e.DataRow.Isnull("第二列") = False OrElse e.DataRow.Isnull("第一列") = False)  Then
            msgbox("第一列第二列已经有值")
            e.Cancel = True
        End If
        
End Select

--  作者:有点蓝
--  发布时间:2017/6/23 23:00:00
--  
Dim lst As new List(of String)
lst.AddRange(new String () {"第一列","第二列","第三列","第四列","第五列"})

Select Case e.DataCol.Name
    Case "第一列","第二列","第三列","第四列","第五列"
        lst.Remove(e.DataCol.Name)
        If e.NewValue > ""
            For Each c As String In lst
                If e.DataRow.Isnull(c) = False Then
                    If MessageBox.Show(c & "已经有值,是否清除","提示",MessageBoxButtons.YesNo) = DialogResult.Yes Then
                        e.DataRow(c) = Nothing
                    Else
                        e.Cancel = True
                        Return
                    End If
                End If
            Next
        End If
        
End Select

--  作者:有点蓝
--  发布时间:2017/6/24 8:40:00
--  
如果不是字符列

If e.NewValue > ""

改为

If  e.DataRow.Isnull(e.DataCol.Name) = false

--  作者:有点蓝
--  发布时间:2017/6/24 16:37:00
--  
请完完全全安装4楼集合的用法做,看不懂代码的不要随便改
--  作者:有点蓝
--  发布时间:2017/6/24 17:37:00
--  
Dim lst As new List(of String)
lst.AddRange(new String () {"投标报价","费率报价","下浮率报价","投标球号"})
Select Case e.DataCol.Name
    Case "投标报价","费率报价","下浮率报价","投标球号"
        lst.Remove(e.DataCol.Name)
        If  e.NewValue IsNot Nothing
            For Each c As String In lst
                If e.DataRow.Isnull(c) = False Then
                    If MessageBox.Show(c & "已经有值,是否清除","提示",MessageBoxButtons.YesNo) = DialogResult.Yes Then
                        e.DataRow(c) = Nothing
                    Else
                        e.Cancel = True
                        Return
                    End If
                End If
            Next
        End If
        
End Select