以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  如何删除所有列  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=100024)

--  作者:2900819580
--  发布时间:2017/5/3 10:43:00
--  如何删除所有列
如下代码,但还是没办法删除所有的列;

Dim tb As Table = Tables(E.Form.Name & "_table1")
Dim dt As DataTable = tb.DataTable
dt.DataRows.Clear


For Each c As Col In tb.Cols
     dt.DataCols.Delete(c.Name)
Next
dt.DataCols.Add("A",Gettype(String),100)

--  作者:有点色
--  发布时间:2017/5/3 11:08:00
--  

Dim tb As Table = Tables(E.Form.Name & "_table1")
Dim dt As DataTable = tb.DataTable
dt.DataRows.Clear

For i As Integer = tb.Cols.count-1 To 0 Step -1
     dt.DataCols.Delete(tb.Cols(i).Name)
Next
dt.DataCols.Add("A",Gettype(String),100)