以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  currenttable.Select(0,2) 是包括隐藏列吗?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=6559)

--  作者:mr725
--  发布时间:2010/4/8 19:13:00
--  currenttable.Select(0,2) 是包括隐藏列吗?
currenttable.Select(0,2) 怎么对可见的列有无效呢,当隐藏第三列后,就无法指向可见的第三列(不隐藏第三列时这个实际是第四列)了,
--  作者:程兴刚
--  发布时间:2010/4/8 19:49:00
--  
这里的2指的是列位置,隐藏与否都不应该改变,不是狐表的问题,想一想就知道为什么!

dim a as Integer
For Each c As Col In currenttable.Cols
    if c.Index <= 2
        if c.Visible = false
            a = a +1
        end if
    end if
Next
currenttable.Select(0,a+2)

--  作者:程兴刚
--  发布时间:2010/4/8 20:23:00
--  

当2设定的值过大,在a+2大于最后列位置时,会报错,可以这样避免:

dim a as Integer
dim b as Integer
For Each c As Col In currenttable.Cols
    if c.Visible = true
        if c.Index <= 8
            a = a +1
        end if
    else
        b = b +1
    end if
Next
if a+b < currenttable.Cols.Count
    currenttable.Select(0,a+8)
else
    MessageBox.show("对不起,指定列大于总列数")
    currenttable.Select(0,0)
end if