以文本方式查看主题

-  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=135841)

--  作者:bashanren
--  发布时间:2019/6/4 14:17:00
--  [讨论]简捷代码

图片点击可在新窗口打开查看此主题相关图片如下:111.png
图片点击可在新窗口打开查看

各位大师下午好!!
如上图,在问题类型分项中的五列为逻辑列,想法是在分项中选为真时,“问题类型”列的值等于分项的列名。我的代码如下,但总觉得应该有简捷的方法,请大师指导,谢谢:
If e.DataCol.Name = "乱占" Then \'如果是乱占列的内容变动
    If e.NewValue = True Then \'而且变动后的值是True(已勾选)
        e.DataRow("问题类型") = "乱占" \'那么当前行的问题类型为乱占
Else
e.DataRow("问题类型") = Nothing \'否则为空值
    End If
End If

If e.DataCol.Name = "乱采" Then
    If e.NewValue = True Then 
        e.DataRow("问题类型") = "乱采"
Else
e.DataRow("问题类型") = Nothing 
    End If
End If

If e.DataCol.Name = "乱堆" Then
    If e.NewValue = True Then 
        e.DataRow("问题类型") = "乱堆"
Else
e.DataRow("问题类型") = Nothing 
    End If
End If

If e.DataCol.Name = "乱建" Then
    If e.NewValue = True Then 
        e.DataRow("问题类型") = "乱建"
Else
e.DataRow("问题类型") = Nothing 
    End If
End If

If e.DataCol.Name = "其他" Then
    If e.NewValue = True Then 
        e.DataRow("问题类型") = "其他"
Else
e.DataRow("问题类型") = Nothing 
    End If
End If

--  作者:y2287958
--  发布时间:2019/6/4 14:25:00
--  
Select Case e.DataCol.Name
    Case "乱占","乱采","乱堆","乱建","其他"
        If e.NewValue = True Then \'而且变动后的值是True(已勾选)
            e.DataRow("问题类型") = e.DataCol.Name \'那么当前行的问题类型为乱占
        Else
            e.DataRow("问题类型") = Nothing \'否则为空值
        End If
End Select

--  作者:bashanren
--  发布时间:2019/6/4 14:51:00
--  
太感谢老师,这确实很简捷了,再次谢谢!!