一开始听到job的要求,还真不知道如何下手,用Gridview?好像有做不到把图片show出来的。在网上搜索一遍,发现原来是ListView与Imglist的结合应用。

看设计:

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Try Me.ListView1.Items.Clear()
Me.imglist.Images.Clear() Dim str As String = ""
Dim strWhere As String = ""
str = "select t1.FEATCODE,t1.FEATTITL,T1.FEATDSC2,t2.featmgid from CD_Features t1 left join CD_FeatureImages t2 on t1.FEATCODE=t2.FEATCODE" & _
" where t1.FEATCODE like '" & Me.txtFeatureCode.Text.Trim & "%' and FEATTITL like '" & Me.txtTitle.Text.Trim & "%'" & _
" and FEATDESC like '%" & Me.txtFeatureDescE.Text.Trim & "%' and FEATDSC2 like '%" & Me.txtFeatureDescC.Text.Trim & "%' " If Me.cboLayer.Text.Trim <> "" Then
str = str & " and substring(t1.FEATCODE,5,2) like'" & Me.cboLayer.SelectedValue.ToString & "%' "
strWhere = strWhere & " and substring(a.FEATCODE,5,2) like'" & Me.cboLayer.SelectedValue.ToString & "%' "
End If
If Me.cboComponent.Text.Trim <> "" Then
str = str & " and substring(t1.FEATCODE,3,2) like'" & Me.cboComponent.SelectedValue.ToString & "%' "
strWhere = strWhere & " and substring(a.FEATCODE,3,2) like'" & Me.cboComponent.SelectedValue.ToString & "%' "
End If
If Me.cboConstrustion.Text.Trim <> "" Then
str = str & " and substring(t1.FEATCODE,7,2) like'" & Me.cboConstrustion.SelectedValue.ToString & "%'"
strWhere = strWhere & " and substring(a.FEATCODE,7,2) like'" & Me.cboConstrustion.SelectedValue.ToString & "%'"
End If Dim dt As DataTable = New DataTable dt = gData.GetDataTable(str, sqlConn) str = "SELECT A.FEATCODE,FEATTITL,SUM(DOPNSMV)SMV FROM dbo.CD_Features A1 INNER JOIN dbo.CD_FeatureOpns A ON A1.FEATCODE=A.FEATCODE" & _
" INNER JOIN dbo.CD_DtledOperationSmv B ON A.DOPNCODE=B.DOPNCODE" & _
" AND A.MACHCODE=B.MACHCODE AND A.STITINCH=B.STITINCH AND A.STITGAUG=B.STITGAUG" & _
" AND A.NEEDLE=B.NEEDLE AND A.BOBBIN=B.BOBBIN AND A.TOPLOOP=B.TOPLOOP" & _
" AND A.UNDLOOP=B.UNDLOOP WHERE A.FEATCODE like '" & Me.txtFeatureCode.Text.Trim & "%' and FEATTITL like '" & Me.txtTitle.Text.Trim & "%'" str = str & strWhere & " GROUP BY A.FEATCODE,FEATTITL" Dim dtSMV As DataTable = New DataTable dtSMV = gData.GetDataTable(str, sqlConn) Dim smv As Decimal = Dim k As Integer = 'imglist Dim indx As Integer = '圖片 For i As Integer = To dt.Rows.Count - Dim dr() As DataRow = dtSMV.Select("FEATCODE='" & dt.Rows(i).Item("FEATCODE").ToString & "'")
If dr.Length > Then
smv = Decimal.Parse(dr().Item("SMV"))
Else
smv =
End If
If dt.Rows(i).Item("featmgid").ToString = "" Then
indx =
Else
indx = Int16.Parse(dt.Rows(i).Item("featmgid").ToString)
End If
Dim command As New SqlCommand("select image from cd_featureimages where FEATCODE='" & dt.Rows(i).Item("FEATCODE") & "' and FEATMGID=" & indx & "", SqlConnect)
Dim by As Byte() = DirectCast(command.ExecuteScalar(), Byte()) Dim myImage As System.Drawing.Image = LoadImage(by) Me.ListView1.Items.Add(dt.Rows(i).Item("FEATCODE").ToString & ",Total SMV:" & smv & "," & Chr() & dt.Rows(i).Item("FEATTITL").ToString & Chr() & dt.Rows(i).Item("FEATDSC2").ToString) If Not myImage Is Nothing Then
k = k +
Me.imglist.Images.Add(myImage)
Me.ListView1.Items(i).ImageIndex = k -
End If
Next Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub Private Function LoadImage(ByVal by As Byte()) As System.Drawing.Bitmap
Try
If by Is Nothing Then
Return Nothing
End If
Me.Cursor = Cursors.WaitCursor
Dim m_PicW As Integer =
Dim m_PicH As Integer =
Dim ms As New IO.MemoryStream(by)
Dim imgT As New PictureBox
imgT.SizeMode = PictureBoxSizeMode.AutoSize
imgT.Image = Image.FromStream(ms) Dim bmp As New System.Drawing.Bitmap(m_PicW, m_PicH)
Dim grp As Graphics = Graphics.FromImage(bmp)
Dim blueBrush As New SolidBrush(Color.White) grp.FillRectangle(blueBrush, , , m_PicW, m_PicH)
Dim intW As Single
Dim intH As Single
If imgT.Width > m_PicW Then
intW = m_PicW
intH = imgT.Height * (m_PicW / imgT.Width)
Else
intW = imgT.Width
intH = imgT.Height
End If
If intH > m_PicH Then
intH = m_PicH
intW = imgT.Width * (m_PicH / imgT.Height)
End If grp.DrawImage(imgT.Image, (m_PicW - intW) / , (m_PicH - intH) / , intW, intH) ms.Close()
Me.Cursor = Cursors.Default
Return bmp
Catch ex As Exception
Me.Cursor = Cursors.Default
MsgBox(ex.ToString, MsgBoxStyle.Critical, CD_SYSTEM_NAME)
Return Nothing
End Try
End Function

模式切换成功!
您可以再次单击恢复。

 

VB ListView罗列图片的更多相关文章

  1. Android在ListView显示图片(重复混乱闪烁问题)

    Android在ListView显示图片(重复混乱闪烁问题) 1.原因分析 ListView item缓存机制: 为了使得性能更优,ListView会缓存行item(某行相应的View). ListV ...

  2. android listview展示图片

    最近学习android开发,感触颇多,和网站开发对比,还是有很大的差距,在这里记录一下. android listview展示图片 在网站开发上,展示图片非常简单,一个HTML img标签就搞定,加上 ...

  3. 【VB技巧】VB ListView 控件功能使用详解

    来源:http://lcx.cc/?i=494 ListView控件 在工具箱上击鼠标右键,选择快捷菜单的Components(部件)项,在控件列表中选择Microsoft Windows Commo ...

  4. vb listview 的常用操作

    常用操作:获取当前行数和列数: MsgBox "行数:" & ListView1.ListItems.Count & "列数:" & L ...

  5. 转 VB ListView控件各种操作详解

    Private Sub Form_Load() ListView1.ListItems.Clear '清空列表 ListView1.ColumnHeaders.Clear '清空列表头 ListVie ...

  6. ListView添加图片文字项

    1)listview 控件 结合 imagelist 控件 实现类似效果. 2)添加 imagelist 控件 images 属性,点击后面的... 添加相应图片. 3)点listview,查看其属性 ...

  7. 转: listview异步图片加载之优化篇(android)

    Listview异步加载之优化篇 关于listview的异步加载,网上其实很多示例了,总体思想差不多,不过很多版本或是有bug,或是有性能问题有待优化.有鉴于此,本人在网上找了个相对理想的版本并在此基 ...

  8. ListView 中图片错位的问题是如何产生的?

    图片错位问题的本质源于我们的 listview 使用了缓存 convertView,假设一种场景,一个 listview 一屏显示九个item,那么在拉出第十个 item 的时候,事实上该 item ...

  9. Android 控件使用教程(一)—— ListView 展示图片

    起因 最近在看一些开源项目时,经常看到了RecyclerView,这是安卓5.0推出的一个新的控件,可以代替传统的ListView,已经这么久了还没有用过,所以决定试一试.另外在做这个的工程中看到了另 ...

随机推荐

  1. 【图像处理】Haar-like特征

    特征提取的原理.代码等: 如果是白黑白,是减去一个黑的还是2个黑的,网上有不同的说法:应该需要看原论文了. 论文原文 The sum of the pixels which lie within th ...

  2. opencv-python教程学习系列3-视频操作

    前言 opencv-python教程学习系列记录学习python-opencv过程的点滴,本文主要介绍视频的获取和保存,坚持学习,共同进步. 系列教程参照OpenCV-Python中文教程: 系统环境 ...

  3. TJU Problem 1065 Factorial

    注意数据范围,十位数以上就可以考虑long long 了,断点调试也十分重要. 原题: 1065.   Factorial Time Limit: 1.0 Seconds   Memory Limit ...

  4. Ajax和SpringMVC之间JSON交互

    Ajax和SpringMVC之间的json数据传输有两种方式: 1.直接传输Json对象 2.将Json序列化成json字符串 1.直接传输Json对象 前端Ajax $(document).read ...

  5. HDU 2108 逆时针给出多边形的顶点,判断是否为凸多边形,水题

    下面是别人解题报告的链接,很详细,写的很好 http://blog.csdn.net/chl_3205/article/details/8520597 下面贴我的代码 #include <cst ...

  6. leetcode:Pascal's Triangle【Python版】

    1.这道题一次提交就AC了: 2.以前用C语言实现的话,初始化二维数组全部为0,然后每行第一个元素为1,只需要用a[i][j] = a[i-1][j]+a[i-1][j-1]就可以了: 3.在Pyth ...

  7. 使用python把html网页转成pdf文件

    我们看到一些比较写的比较好文章或者博客的时候,想保存下来到本地当一个pdf文件,当做自己的知识储备,以后即使这个博客或者文章的连接不存在了,或者被删掉,咱们自己也还有. 当然咱们作为一个coder,这 ...

  8. Apache+modproxy布置tomcat集群

    一.环境: Apache: 2.2.14: 下载地址:http://archive.apache.org/dist/httpd/binaries/win32/ Tomcat: 7.0.82 JDK1. ...

  9. 【转】每天一个linux命令(44):top命令

    原文网址:http://www.cnblogs.com/peida/archive/2012/12/24/2831353.html top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进 ...

  10. MYSQL的空间查询(转帖)

    SELECT x(location),y(location) FROM frddata.points; 本文将向各位介绍如何使用MySql5.x中的空间数据库,并展示一下它高效的性能(前提是正确使用) ...