以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 帮我看看哪里错了? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=146433) |
-- 作者:hongye -- 发布时间:2020/2/23 23:40:00 -- 帮我看看哪里错了? 帮我看看这个哪里错了?为什么会出现错误? Dim fr As String fr = e.Form.name & "_" Dim lvw As WinForm.ListView = e.Form.Controls("ListView1") Dim vr As WinForm.ListViewRow = lvw.Current \'获取ListView的当前行 Dim dr As DataRow = vr.tag Dim lr As WinForm.ListViewRow = e.Sender.Current MessageBox.Show("你双击的是:" & lr.Text & " " & lr.Group) Dim n As String = lr.Group & "核价" Dim tbl As WinForm.Table tbl = e.Form.CreateSQLTable(n, "Select * fr om {" & n & "}" ,"彬阳数据") tbl.SetBounds(21, 11, 75, 30) tbl.Visible = False e.Form.AddControl(tbl) MessageBox.Show( Tables(fr & n).Cols.Count) Dim ps As Integer = Tables(fr & n).FindRow(dr) MessageBox.Show("1") If ps >= 0 Then Forms("窗口2").Open() Tables(fr & n).Position = ps For i As Integer = 1 To 15 Forms("窗口2").RemoveControl("TBt" & i) Forms("窗口2").RemoveControl("lbt" & i) Next Dim cnt As Integer For Each c As WinForm.Control In Forms("窗口2").Controls If Typeof c Is WinForm.TextBox Then \'判断控件是否是文本框 If c.Name.StartsWith("TextBox") Then \'而且名称是以TextBox开头 cnt += 1 End If End If Next \'MessageBox.Show("控件数量:" & cnt) Forms("窗口2").Controls("Label2").text = n Forms("窗口2").Controls("Label1").text = Tables(fr & n).Current(5) For i As Integer = 1 To 2 Forms("窗口2").Controls("Label" & i).Font = New Font("黑体",12,FontStyle.Regular) Next For i As Integer = 1 To Tables(fr & n).Cols.Count - 5 Dim lxt As WinForm.Label lxt = Forms("窗口2").CreateControl("lbt" & i, ControlTypeEnum.Label) If i < 6 lxt.Left = 40 lxt.Top = 65+(i)*30 lxt.Height = 23 lxt.Width = 130 lxt.Text = Tables(fr & n).Cols(i+4).Name & ":" lxt.TextAlign= ContentAlignment.MiddleRight lxt.Font = New Font("黑体",12,FontStyle.Regular) Else lxt.Left = 340 lxt.Top = 67+(i-5)*30 lxt.Height = 23 lxt.Width = 130 lxt.Text = Tables(fr & n).Cols(i+4).Name & ":" lxt.TextAlign= ContentAlignment.MiddleRight lxt.Font = New Font("黑体",12,FontStyle.Regular) End If Forms("窗口2").AddControl(lxt) Dim TBt As WinForm.TextBox TBt = Forms("窗口2").CreateControl("TBt" & i, ControlTypeEnum.TextBox) If i < 6 TBt.Left = 180 TBt.Top = 65+(i)*30 TBt.Height = 23 TBt.Width = 150 Select Case Tables(fr & n).Cols(i+4).Name Case "单价" , "金额" TBt.Value = Format(Round2(Tables(fr & n).Current(Tables(fr & n).Cols(i+4).Name),2),"n") Case Else TBt.Value = Tables(fr & n).Current(Tables(fr & n).Cols(i+4).Name) End Select \'TBt.TextAlign= ContentAlignment.MiddleRight TBt.Font = New Font("黑体",12,FontStyle.Regular) Else TBt.Left = 470 TBt.Top = 65+(i-5)*30 TBt.Height = 23 TBt.Width = 150 Select Case Tables(fr & n).Cols(i+4).Name Case "单价" , "金额" TBt.Value = Format(Round2(Tables(fr & n).Current(Tables(fr & n).Cols(i+4).Name),2),"n") Case Else TBt.Value = Tables(fr & n).Current(Tables(fr & n).Cols(i+4).Name) End Select \'TBt.TextAlign= ContentAlignment.MiddleRight TBt.Font = New Font("黑体",12,FontStyle.Regular) End If Forms("窗口2").AddControl(TBt) Next End If If e.Form.ExistControl(n) Then e.Form.RemoveControl(n) End If
[此贴子已经被作者于2020/2/23 23:40:12编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/2/24 9:25:00 -- Tables(fr & n)是刚刚使用CreateSQLTable创建出来的,是一个全新的table,同样背后会有一个全新的datatable对应。 而【Dim dr As DataRow = vr.tag】里的导入这个DataRow 应该是之前通过其它table生成的。不同的两个table的行是不能使用FindRow(dr)这种用法的,改为 条件查询,如 Dim ps As Integer = Tables(fr & n).FindRow("某某编号=\'" & dr("某某编号") & "\'")
|