以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 帮我看看哪里错了? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=146609) |
-- 作者:hongye -- 发布时间:2020/2/27 14:52:00 -- 帮我看看哪里错了? ValueChanged事件 Dim cj As WinForm.DropDownBox = e.Form.Controls("样衣款号") Dim dm As WinForm.DropDownBox = e.Form.Controls("款号") Dim lvw As WinForm.ListView = e.Form.Controls("ListView1") Dim fr As String fr = e.Form.name & "_" \'--------------------------基本设置-------------------------------------- Dim gps() As String = {"面料","辅料","二次加工"} \'定义分组名称 Dim dt As DataTable = DataTables(fr & "面料核价") Dim dt1 As DataTable = DataTables(fr & "辅料核价") Dim dt2 As DataTable = DataTables(fr & "二次加工核价") Dim drs = dt.Select("款号 = \'" & dm.Text & "\'and 样衣号 like \'%" & cj.Text & "%\'", "_sortkey") Dim drs1 = dt1.Select("款号 = \'" & dm.Text & "\'and 样衣号 like \'%" & cj.Text & "%\'", "_sortkey") Dim drs2 = dt2.Select("款号 = \'" & dm.Text & "\'and 样衣号 like \'%" & cj.Text & "%\'", "_sortkey") lvw.StopRedraw() \'暂停绘制 lvw.Groups.Clear() \'清除原来的分组 lvw.Columns.Clear() \'清除原来的列 lvw.Rows.Clear() \'清除原来的行 lvw.View = ViewMode.Details \'显示模式为详细信息 lvw.GridLines = True \'显示网格线 \'--------------------------标题-------------------------------------- Dim cls() As String = {"项目名称","规格","成份或质地","克重","门幅","单位","单耗","单价","金额","供应商"} \'定义列名 Dim wds() As String = {140,130,90,45,45,45,58,65,70,90} \'定义列宽 For i As Integer = 0 To cls.Length - 1 \'增加列 Dim c As WinForm.ListViewColumn = lvw.Columns.Add() c.Text = cls(i) \'指定列标题 c.Name = cls(i) \'指定列名 c.Width = wds(i) \'指定列宽 Next lvw.Columns("克重").TextAlign = HorizontalAlignment.Right \'靠右对齐 lvw.Columns("门幅").TextAlign = HorizontalAlignment.Right \'靠右对齐 lvw.Columns("单耗").TextAlign = HorizontalAlignment.Right \'靠右对齐 lvw.Columns("单价").TextAlign = HorizontalAlignment.Right \'靠右对齐 lvw.Columns("金额").TextAlign = HorizontalAlignment.Right \'靠右对齐 \'--------------------------分组-------------------------------------- For Each gp As String In gps Dim vg As WinForm.ListViewGroup = lvw.Groups.Add() \'增加分组 vg.Name = gp \'指定分组名称 vg.Text = gp \'指定分组标题 Next \'-------------------------------------------------------------------- Dim grp As WinForm.ListViewGroup = lvw.Groups.Add() For Each dr As DataRow In drs Dim r As WinForm.ListViewRow = lvw.Rows.Add() \'增加一行 r.tag = dr If dr("单耗") > 0 Then \'单耗列数值大于0的单元格,用Blue字显示 r.CellUseRowStyle = False \'必须将行的CellUseRowStyle属性设置为False,才能单独设置此行单元格的格式 With r.Cells("单耗") .ForeColor = Color.Blue End With End If If dr("单价") > 0 Then \'单耗列数值大于0的单元格,用Blue字显示 r.CellUseRowStyle = False \'必须将行的CellUseRowStyle属性设置为False,才能单独设置此行单元格的格式 With r.Cells("单价") .ForeColor = Color.Maroon End With End If If dr("金额") > 0 Then \'单耗列数值大于0的单元格,用Blue字显示 r.CellUseRowStyle = False \'必须将行的CellUseRowStyle属性设置为False,才能单独设置此行单元格的格式 With r.Cells("金额") .ForeColor = Color.Indigo End With End If \'----------------------分组1---------------------------------- r.Group = gps(0) \'----------------------填入第1个分组数据---------------------------------- r("项目名称") = dr("面料名称") r("规格") = dr("规格") r("成份或质地") = dr("成份") r("克重") = dr("克重") r("门幅") = dr("门幅") r("单位") = dr("计量单位") r("单耗") = dr("单耗") r("单价") = Format(Round2(dr("单价"),2),"n") r("金额") = Format(Round2(dr("金额"),2),"n") r("供应商") = dr("供应商") Next \'-------------------------------------------------------------------- For Each dr1 As DataRow In drs1 Dim r As WinForm.ListViewRow = lvw.Rows.Add() \'增加一行 r.tag = dr1 If dr1("单耗") > 0 Then \'单耗列数值大于0的单元格,用Blue字显示 r.CellUseRowStyle = False \'必须将行的CellUseRowStyle属性设置为False,才能单独设置此行单元格的格式 With r.Cells("单耗") .ForeColor = Color.Blue End With End If If dr1("单价") > 0 Then \'单耗列数值大于0的单元格,用Blue字显示 r.CellUseRowStyle = False \'必须将行的CellUseRowStyle属性设置为False,才能单独设置此行单元格的格式 With r.Cells("单价") .ForeColor = Color.Maroon End With End If If dr1("金额") > 0 Then \'单耗列数值大于0的单元格,用Blue字显示 r.CellUseRowStyle = False \'必须将行的CellUseRowStyle属性设置为False,才能单独设置此行单元格的格式 With r.Cells("金额") .ForeColor = Color.Indigo End With End If \'----------------------分组2---------------------------------- r.Group = gps(1) \'----------------------填入第2个分组数据---------------------------------- r("项目名称") = dr1("辅料名称") r("规格") = dr1("规格") r("成份或质地") = dr1("辅料质地") r("克重") = dr1("克重") r("门幅") = dr1("门幅") r("单位") = dr1("计量单位") r("单耗") = dr1("单耗") r("单价") = Format(Round2(dr1("单价"),2),"n") r("金额") = Format(Round2(dr1("金额"),2),"n") r("供应商") = dr1("供应商") Next \'-------------------------------------------------------------------- For Each dr2 As DataRow In drs2 Dim r As WinForm.ListViewRow = lvw.Rows.Add() \'增加一行 r.tag = dr2 If dr2("数量") > 0 Then \'单耗列数值大于0的单元格,用Blue字显示 r.CellUseRowStyle = False \'必须将行的CellUseRowStyle属性设置为False,才能单独设置此行单元格的格式 With r.Cells("单耗") .ForeColor = Color.Blue End With End If If dr2("单价") > 0 Then \'单耗列数值大于0的单元格,用Blue字显示 r.CellUseRowStyle = False \'必须将行的CellUseRowStyle属性设置为False,才能单独设置此行单元格的格式 With r.Cells("单价") .ForeColor = Color.Maroon End With End If If dr2("金额") > 0 Then \'单耗列数值大于0的单元格,用Blue字显示 r.CellUseRowStyle = False \'必须将行的CellUseRowStyle属性设置为False,才能单独设置此行单元格的格式 With r.Cells("金额") .ForeColor = Color.Indigo End With End If \'----------------------分组3---------------------------------- r.Group = gps(2) \'----------------------填入第3个分组数据---------------------------------- r("项目名称") = dr2("二次加工名称") r("规格") = "" r("成份或质地") = "" r("克重") = "" r("门幅") = "" r("单位") = dr2("计量单位") r("单耗") = dr2("数量") r("单价") = Format(Round2(dr2("单价"),2),"n") r("金额") = Format(Round2(dr2("金额"),2),"n") r("供应商") = dr2("供应商") Next lvw.ResumeRedraw 无法正常在ListView里显示数据 要求是点击DropDownBox,出现下拉菜单DropDownForm,选中列表后,在在ListView里显示相应的数据
|
-- 作者:程兴刚 -- 发布时间:2020/2/27 15:07:00 -- 多处"\'and这里双引号后面缺空格!其他没细看! |
-- 作者:有点蓝 -- 发布时间:2020/2/27 15:09:00 -- 调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm 没有符合条件的结果 msgbox("款号 = \'" & dm.Text & "\'and 样衣号 like \'%" & cj.Text & "%\'") Dim drs = dt.Select("款号 = \'" & dm.Text & "\'and 样衣号 like \'%" & cj.Text & "%\'", "_sortkey") msgbox(drs.count) Dim drs1 = dt1.Select("款号 = \'" & dm.Text & "\'and 样衣号 like \'%" & cj.Text & "%\'", "_sortkey") msgbox(drs1.count) Dim drs2 = dt2.Select("款号 = \'" & dm.Text & "\'and 样衣号 like \'%" & cj.Text & "%\'", "_sortkey") msgbox(drs2.count) |
-- 作者:hongye -- 发布时间:2020/2/27 16:52:00 -- 找到问题了,之前表已经筛选了 但是还有一个问题,当点击DropDownBox选中列表显示后,如果再点击DropDownBox后,ListView里就没法显示数据了,这是为什么?
|
-- 作者:有点蓝 -- 发布时间:2020/2/27 17:01:00 -- 仍然看3楼 |