以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]请帮修改afteredit中的代码(已解决)  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=1863)

--  作者:mr725
--  发布时间:2009/2/18 19:18:00
--  [求助]请帮修改afteredit中的代码(已解决)
光标在第十行任何一个单元格时,只要按del键和enter键,就会出现错误提示,不知是什么原因?
请老师们帮修改一下AfterEdit事件中的代码! 另外:当品名列为空时要清空这一行的所有列的内容!(不是删除行)
AfterEdit事件中的代码:
   Dim pm As string = Tables("表A").Current("品名")
   Dim pmb As DataRow = DataTables("表B").Find("[品名]  = \'" & pm & "\'")                
       Tables("表A").Current("编号") = pmb("编号")
       If  Tables("表A").Current("部门") is nothing andalso pmb("部门") = -1 Then
                   
               Messagebox.Show("请选择部门!", "提示",MessageBoxButtons.OK)
                    Dim bm As string = Tables("表A").Current("部门")
                      If bm Is Nothing Then          
                           e.Table.Select(e.Table.RowSel, e.Table.Cols("部门").Index -1)
                      End If                    
         End If
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目2.table

[此贴子已经被作者于2009-2-18 20:27:04编辑过]

--  作者:mr725
--  发布时间:2009/2/18 19:33:00
--  
修改了一下好像不会提示错误了 
Dim pm As string = Tables("表A").Current("品名")
 Dim pmb As DataRow = DataTables("表B").Find("[品名]  = \'" & pm & "\'")
            if Tables("表A").Current("品名") = nothing then
                        Tables("表A").Current("编号") = nothing \'这下面几行能简化一下吗?如果整行清空怎么写?
                        Tables("表A").Current("数量") = nothing
                        Tables("表A").Current("启用日期") = nothing
                        Tables("表A").Current("部门") = nothing
            else
               
                        Tables("表A").Current("编号") = pmb("编号")
             If  Tables("表A").Current("部门") is nothing andalso pmb("部门") = -1 Then
                   
               Messagebox.Show("请选择部门!", "提示",MessageBoxButtons.OK)
                    Dim bm As string = Tables("表A").Current("部门")
                      If bm Is Nothing Then          
                           e.Table.Select(e.Table.RowSel, e.Table.Cols("部门").Index -1)
                      End If
                   
              End If
             End If
[此贴子已经被作者于2009-2-18 19:33:44编辑过]

--  作者:狐狸爸爸
--  发布时间:2009/2/18 20:17:00
--  
 Tables("表A").Current("编号") = nothing \'这下面几行能简化一下吗?如果整行清空怎么写?
                        Tables("表A").Current("数量") = nothing
                        Tables("表A").Current("启用日期") = nothing
                        Tables("表A").Current("部门") = nothing


简化:

For each c AS Col in  Tables("表A").Cols
    Tables("表A").Current(c.name) = Nothing
Next
--  作者:mr725
--  发布时间:2009/2/18 20:27:00
--  
谢谢!~