以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  行列定位编辑问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=193722)

--  作者:lgz518
--  发布时间:2024/10/8 9:30:00
--  行列定位编辑问题

此主题相关图片如下:光标问题.png
按此在新窗口浏览图片
需求:如何实现表A的方向,如果方向为A时,光标在第一列,且为可编辑,其他为不编辑,编辑后自动跳到下一行,
如果方向为B时,光标在第二列,且为可编辑,其他为不编辑,编辑后自动跳到下一行,

--  作者:有点蓝
--  发布时间:2024/10/8 10:38:00
--  
prepareedit事件
if e.col.name = "第一列" then
if e.row("方向") <> “A”
e.cancel=true
end if
elseif e.col.name = "第二列" then
if e.row("方向") <> “B”
e.cancel=true
end if
else
e.cancel=true
end if

keydownedit事件
if e.KeyCode=keys.enter then
if e.row.index < e.table.rows.count - 1
if e.row("方向") = "A"
e.table.select(e.row.index+1,1)
e.cancel=true
elseif e.row("方向") = "B"
e.table.select(e.row.index+1,2)
e.cancel=true
en dif
end if
end if

--  作者:lgz518
--  发布时间:2024/10/8 15:03:00
--  
下面文字的代码如何实现?
If e.DataCol.Name ="方向" Then \'
    If e.Row("方向") = "A" AndAlso e.Row("方向") IsNot Nothing Then
           光标在当前表、表A当前的第一列,可编辑,第二列为不可编辑
    End If
    If e.Row("方向") = "B" AndAlso e.Row("方向") IsNot Nothing Then
           光标在当前表、表A当前的第二列,可编辑,第一列为不可编辑
    End If
EndIf

--  作者:有点蓝
--  发布时间:2024/10/8 15:10:00
--  
可否编辑,和光标设置必须分开2个事件。看2楼
--  作者:lgz518
--  发布时间:2024/10/8 15:34:00
--  
prepareedit事件
if e.col.name = "第一列" then
if e.row("方向") <> “A”
e.cancel=true
end if
elseif e.col.name = "第二列" then
if e.row("方向") <> “B”
e.cancel=true
end if
else
e.cancel=true
end if


If e.Col.name = "第一列" AndAlso e.Row.IsNull("方向") = False Then
    If e.Row("方向") <> "A" Then
        e.cancel = True
    End If
ElseIf e.Col.name = "第二列" AndAlso e.Row.IsNull("方向") = False Then
    If e.Row("方向") <> "B" Then
        e.cancel = True
    End If
Else
    e.cancel = True
End If


这个试一下,当方向为空时,都锁表。不是需求,如何解决?
需求:方向为空时表可编辑,如果方向为A时,第一列可编辑,第二列不可编辑,如果方向为B时,第二列可编辑,第一列不可编辑,

--  作者:有点蓝
--  发布时间:2024/10/8 16:09:00
--  
if e.Row.IsNull("方向") = False then
If e.Col.name = "第一列" Then
    If e.Row("方向") <> "A" Then
        e.cancel = True
    End If
ElseIf e.Col.name = "第二列" Then
    If e.Row("方向") <> "B" Then
        e.cancel = True
    End If
End If
End If

--  作者:lgz518
--  发布时间:2024/10/8 17:18:00
--  
\'KeyPressEdit

 If e.Col.name = "方向" Then \'
      If e.Row("方向") = "A" Then\'
        光标位置=e.Row("第一列")
      
   ElseIf e.Row("方向") = "B" Then\'

      光标位置=e.Row("第二列") 
    End If
End If

标颜色如何实现,如果("方向") 录入 "A"或("方向") = "A"时,录入光标跳转到第一列,如果("方向") 录入 "A"或("方向") = "A"时,录入光标跳转到第二列?


--  作者:有点蓝
--  发布时间:2024/10/8 17:29:00
--  
keydownedit事件

If e.Col.Name = "方向" andalso e.KeyCode=keys.enter  Then
  if e.text = "A"
e.table.select(e.row.index,e.table.cols("第一列").index)
e.cancel=true
elseif e.text  = "B"
e.table.select(e.row.index,e.table.cols("第二列").index)
e.cancel=true
endif
End If

--  作者:lgz518
--  发布时间:2024/10/8 18:59:00
--  
这种是要录入后,要按回车,才能看变化,如何实现在下拉列表选择后或跨表引入后,光标就能按条件跳转到指定列?
--  作者:有点蓝
--  发布时间:2024/10/8 20:09:00
--  
datacolchanged事件

If e.dataCol.Name = "方向Then
  if e.newvlaue = "A"
dim idx as integer = tabels("当前表名").findrow(e.datarow)
tabels("当前表名").select(idx ,tabels("当前表名").cols("第一列").index)
elseif e.newvlaue = "B"
dim idx as integer = tabels("当前表名").findrow(e.datarow)
tabels("当前表名").select(idx ,tabels("当前表名").cols("第二列").index)
endif
End If