老师,图片问题这样解决字母处理,把彩色转成黑白,论坛上这样写的:
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter = "图片文件|*.jpg;*.png" '设置筛选器
If dlg.ShowDialog = DialogResult.OK Then '如果用户单击了确定按钮
Dim omg As Image = GetImage(dlg.FileName)
Windows.Forms.ControlPaint.DrawImageDisabled(Graphics.FromImage(omg), omg, 0, 0, Color.Transparent)
e.Form.Controls("PictureBox1").Image = omg
End If
我现在这个把不可用字母转成黑白:
Dim pag As WinForm.TabControl = Forms("主窗口").Controls("tabControl2")
Dim dru As DataRow = DataTables("用户管理").SQLFind("账号='" & _UserName & "'")
If dru Is Nothing Then : Return 0 : End If
Dim kjjhs() As String = dru("菜单可见集合").Split(",")
Dim kyjhs() As String = dru("菜单可用集合").Split(",")
For Each fl As String In DataTables("导航").GetValues("分类","[分类]<> '"& pag.SelectedPage.Name & "'","序号") '增加分类
If Array.IndexOf(kjjhs,fl) = -1 Then '跳过不可见的页面插入
Continue For
End If
If pag.TabPages(fl) Is Nothing Then
Dim pc As object = pag.TabPages.Add(fl,fl) '新增加页签
Dim dr As DataRow = DataTables("导航").Find("分类 = '" & fl & "'")
If dr IsNot Nothing Then
pc.Image= GetImage(dr("分类图标")) '增加页签图标
End If
End If
Next
Dim lvw As WinForm.ListView = forms("主窗口").Controls("ListView1")
lvw.StopRedraw() '停止绘制
lvw.Groups.Clear() '清除原来的分组
lvw.Columns.Clear() '清除原来的列
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.Details '显示模式为详细信息
lvw.TitleSize = New Size(130,80) '设置平铺区域大小
lvw.GridLines = True '显示网格线
Dim cls() As String = {"名称"} '定义列名
Dim wds() As Integer = {100} '定义列宽
For i As Integer = 0 To cls.Length - 1 '增加列
Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
c.Name = cls(i) '指定列名
c.Text = cls(i) '指定标题,这里标题和列名相同
c.Width = wds(i) '指定列宽
Next
Dim drs As List(of DataRow )= DataTables("导航").Select ("[分类] = '"& pag.SelectedPage.Name & "'","序号") '增加分组
For Each dr As DataRow In drs
If array.IndexOf(kjjhs,dr("名称")) = -1 Then '不可见的跳过
Continue For
End If
If lvw.Groups.contains(dr("分组")) =False Then
Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
grp.Name = dr("分组")
grp.Text = dr("分组")
End If
Dim r As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
Dim key As String= dr("图标")
lvw.Images.AddImage(Key, Key, Key) '添加代表这个名称的一对图标
r.ImageKey = Key '指定图标键值
r.Group = dr("分组") '指定所属分组
r.Tag = dr
For Each cl As String In cls '逐列取值
r(cl) = dr(cl)
Next
If array.IndexOf(kyjhs,dr("名称")) = -1 Then '不可用的着色
r.ForeColor= Color.Red
End If
lvw.ResumeRedraw() '恢复绘制
lvw.View = ViewMode.LargeIcon '显示模式切换为大图标
Next