以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助] 用代码增加的表 Ctrl +D 功能实现  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=119157)

--  作者:2900819580
--  发布时间:2018/5/18 17:02:00
--  [求助] 用代码增加的表 Ctrl +D 功能实现

如下用代码增加的表,我想做到有Ctrl+D功能,这个代码要写在那里?

 

 

Dim tb As Table = CurrentTable
Dim r As Row = tb.Current
If r Is Nothing Then Return
If r("i") = "+" OrElse r("i") = "--" Then
    Dim tab As WinForm.TabControl = e.Form.Controls("TabControl1")
    Dim id As Integer = tab.TabPages.Count
    \' Dim tbn As String = "TabMc" & id
    Dim tbn As String = "TabMc" & Format(Functions.Execute("返回服务器日期"),"HHmmss")
    tab.TabPages.Add(Tbn,r("名称"))
    tab.SelectedIndex = id
    Dim CVS As String = tb.GetColVisibleWidth
    \'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~?
    If e.form.controls.contains(tbn) Then
        MessageBox.Show("移除")
        e.form.RemoveControl(tbn)
    End If
   
    Dim tbl As WinForm.Table
    tbl = e.Form.CreateSQLTable(tbn ,"Sele ct * Fro m {BOM} where 父阶代码 = \'" & r("子阶代码") & "\'", "ksg")
   
    tbl.Dock = 5
    e.Form.Controls("TabControl1").Tabpages(id).AddControl(tbl)
    tbl.ContextStrip = e.Form.Strips("快捷菜单1")
    tbl.Table.SetColVisibl eWidth("i|16|序号|34|子阶代码|158|名称|195|规格型号|244|单位|34|用量|47|选用料|47|车间|34|组别|47|替换料|47|默认仓库名称|84")
    tbl.Table.Sort = "序号"
    tbl.Table.Cols("子阶代码").DropForm = "物料表查找下拉"
End If


--  作者:有点甜
--  发布时间:2018/5/18 17:50:00
--  

你可以在全局表事件keydown事件写代码

 

If e.keycode = Keys.D AndAlso e.control = True Then
    For i As Integer = e.Table.topposition + 1 To e.Table.bottomposition
        e.Table.rows(i)("第二列") = e.Table.rows(i-1)("第二列")
    Next
    e.cancel = True
End If

 

全局表事件需要在你生成窗口表之后开启的 http://www.foxtable.com/webhelp/scr/0671.htm

 


--  作者:2900819580
--  发布时间:2018/5/19 11:12:00
--  

If e.keycode = Keys.D AndAlso e.control = True Then
    For i As Integer = e.Table.topposition + 1 To e.Table.bottomposition
        e.Table.rows(i)(e.Table.Cols(e.Table.ColSel).Name) = e.Table.rows(i-1)(e.Table.Cols(e.Table.ColSel).Name)
    Next
    e.cancel = True
End If

 

 

Dim tb As Table = CurrentTable
Dim r As Row = tb.Current
If r Is Nothing Then Return
If r("i") = "+" OrElse r("i") = "--" Then
    Dim tab As WinForm.TabControl = e.Form.Controls("TabControl1")
    Dim id As Integer = tab.TabPages.Count
    \' Dim tbn As String = "TabMc" & id
    Dim tbn As String = "TabMc" & Format(Functions.Execute("返回服务器日期"),"HHmmss")
    tab.TabPages.Add(Tbn,r("名称"))
    tab.SelectedIndex = id
    Dim CVS As String = tb.GetColVisibleWidth
    \'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~?
    If e.form.controls.contains(tbn) Then
        MessageBox.Show("移除")
        e.form.RemoveControl(tbn)
    End If
   

tb.datatable.GlobalHandler.KeyDown = True \'这行代码加在这里吗?测试过,不行哟!


    Dim tbl As WinForm.Table
    tbl = e.Form.CreateSQLTable(tbn ,"Sele ct * Fro m {BOM} where 父阶代码 = \'" & r("子阶代码") & "\'", "ksg")
   
    tbl.Dock = 5
    e.Form.Controls("TabControl1").Tabpages(id).AddControl(tbl)
    tbl.ContextStrip = e.Form.Strips("快捷菜单1")
    tbl.Table.SetColVisibl eWidth("i|16|序号|34|子阶代码|158|名称|195|规格型号|244|单位|34|用量|47|选用料|47|车间|34|组别|47|替换料|47|默认仓库名称|84")
    tbl.Table.Sort = "序号"
    tbl.Table.Cols("子阶代码").DropForm = "物料表查找下拉"
End If

 

 


--  作者:有点蓝
--  发布时间:2018/5/19 11:16:00
--  
放到窗口afterload事件

tables("某某表").datatable.lobalHandler.KeyDown = True

--  作者:2900819580
--  发布时间:2018/5/19 14:02:00
--  
以下是引用有点蓝在2018/5/19 11:16:00的发言:
放到窗口afterload事件

tables("某某表").datatable.lobalHandler.KeyDown = True

 

老师,我的表是通过tab.TabPages.Add(Tbn,r("名称"))  新增的,


--  作者:有点蓝
--  发布时间:2018/5/19 14:42:00
--  
……
Dim tbl As WinForm.Table
    tbl = e.Form.CreateSQLTable(tbn ,"Sele ct * Fro m {BOM} where 父阶代码 = \'" & r("子阶代码") & "\'", "ksg")
    
    tbl.Dock = 5
    e.Form.Controls("TabControl1").Tabpages(id).AddControl(tbl)
    tbl.ContextStrip = e.Form.Strips("快捷菜单1")
    tbl.Table.SetColVisibl eWidth("i|16|序号|34|子阶代码|158|名称|195|规格型号|244|单位|34|用量|47|选用料|47|车间|34|组别|47|替换料|47|默认仓库名称|84")
    tbl.Table.Sort = "序号"
    tbl.Table.Cols("子阶代码").DropForm = "物料表查找下拉"
    tbl.Table.datatable.lobalHandler.KeyDown = True
End If