以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]全局代码求助  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=94710)

--  作者:cqlwsam
--  发布时间:2016/12/30 8:59:00
--  [求助]全局代码求助
窗口中动态添加的recordgrid控件,想给该recordgrid控件添加事件代码,当点击控件中每行,获取改行的标题,通过标题筛选相应的正常值及临床意义填入相应的textbox控件中。

全局代码怎么弄呀?谢谢!



图片点击可在新窗口打开查看此主题相关图片如下:360反馈意见截图182805125782112.png
图片点击可在新窗口打开查看





[此贴子已经被作者于2016/12/30 8:59:44编辑过]

--  作者:cqlwsam
--  发布时间:2016/12/30 9:09:00
--  
这是我在窗口的全局事件中的代码:
Dim s1() As String
Dim t,s2 As String
Dim dt As Table = Tables("临床资料登记_table1")
If dt.Current IsNot Nothing Then
    t=dt.Current("信息编号")
    s1= t.Split("-")
    s2 = s1(2)
    If s2 Like "05*" Then
        For Each c As WinForm.Control In e.Form.Controls
            If Typeof c Is winform.recordgrid Then
                Dim g As WinForm.RecordGrid=c
                Dim bctr = g.baseControl
                For Each r As object In bctr.Rows
                    For Each r1 As Row In Tables("实验室检查维护").Rows
                        If r.caption = r1("检验项目") Then
                            Forms("临床资料登记").controls("TextBox2").value=r1("正常值")
                            MessageBox.show(r1("正常值"))
                            forms("临床资料登记").controls("TextBox3").value=r1("临床意义")
                        End If
                    Next
\'                    msgbox(r.caption)
\'                    msgbox(r(1))
                Next
            End If
        Next
    End If
End If


需要用全局代码换掉:

For Each r As object In bctr.Rows
                    For Each r1 As Row In Tables("实验室检查维护").Rows
                        If r.caption = r1("检验项目") Then
                            Forms("临床资料登记").controls("TextBox2").value=r1("正常值")
                            MessageBox.show(r1("正常值"))
                            forms("临床资料登记").controls("TextBox3").value=r1("临床意义")
                        End If
                    Next
\'                    msgbox(r.caption)
\'                    msgbox(r(1))
                Next
[此贴子已经被作者于2016/12/30 9:10:28编辑过]

--  作者:cqlwsam
--  发布时间:2016/12/30 9:18:00
--  
如果全局代码是这样:

Public Sub recordgrid_RowColChange (sender As object, e As C1.Win.C1FlexGrid.RowColEventArgs)
End Sub

sender传的是什么? e传的是什么?

--  作者:有点色
--  发布时间:2016/12/30 9:18:00
--  

 直接获取值,不就好了?

 

Dim grid = 你绑定事件的sender参数

dim r as integer = grid.Selection.r1
dim c as integer = grid.selection.c1
msgbox(grid(r,c).tostring)
msgbox(grid(r,1).tostring)


--  作者:cqlwsam
--  发布时间:2016/12/30 12:29:00
--  
在recordgrid控件,我想取第1列第3个的值,代码怎么弄?
Dim g As WinForm.RecordGrid=c
                Dim g1 As C1.Win.C1FlexGrid.C1FlexGridBase = g.baseControl
                addhandler g1.MouseEnterCell, addressof MouseEnterCellHandler
                addhandler g1.click, addressof clickhandler
                t1=g1.cols(ra).caption

ra是行数

--  作者:有点色
--  发布时间:2016/12/30 12:31:00
--  
msgbox(g1(行数,列数).tostring)