如何设置ListView控件背景色,最好是间隔的,就像CSDN的各个贴子之间的间隔色一样!

blueheart9734 2003-08-21 04:44:29
如题,谢谢~~
...全文
63 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
射天狼 2003-08-21
  • 打赏
  • 举报
回复
Option Explicit

'添加一个PictureBox控件,名称为:picGreenbar
Private Sub Form_Load()
'Vars for greenbar code
Dim i As Integer
Dim iFontHeight As Long
Dim iBarHeight As Integer
Dim j As Integer
Dim itmX As ListItem
Dim ColHead As ColumnHeader
ListView1.ColumnHeaders.Add , , "This is Just a Simple Example"
ListView1.ColumnHeaders(1).Width = 3000


For j = 1 To 33
Set itmX = ListView1.ListItems.Add()
itmX.Text = "This is item number " & CStr(j)
Next j
Me.ScaleMode = vbTwips 'make sure our form is In twips
picGreenbar.ScaleMode = vbTwips
picGreenbar.BorderStyle = vbBSNone 'this is important - we don't want To measure the border In our calcs.
picGreenbar.AutoRedraw = True
picGreenbar.Visible = False
picGreenbar.Font = ListView1.Font
iFontHeight = picGreenbar.TextHeight("b") + Screen.TwipsPerPixelY
iBarHeight = (iFontHeight * 1) '3 line wide greenbars.
picGreenbar.Width = ListView1.Width
'======
picGreenbar.Height = iBarHeight * 2
picGreenbar.ScaleMode = vbUser
picGreenbar.ScaleHeight = 2 '2 bar-widths high
picGreenbar.ScaleWidth = 1 '1 bar-width wide
'draw the actual bars
picGreenbar.Line (0, 0)-(1, 1), vbWhite, BF 'white bars - modify vbWhite To change bar color
picGreenbar.Line (0, 1)-(1, 2), RGB(227, 241, 226), BF 'light green bars - modify RGB(x,x,x) To change bar color
'======
'put it in the listview control, tiled
ListView1.PictureAlignment = lvwTile
ListView1.Picture = picGreenbar.Image
End Sub
射天狼 2003-08-21
  • 打赏
  • 举报
回复
strongfisher 2003-08-21
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=7273
没法下载,到这里折腾一把试试。 本文由abc2253130贡献 doc文档可能在WAP端浏览体验不佳。建议您优先选择TXT,或下载源文件到本机查看。 C#(WINFORM)学习 一、 C#基础 基础 类型和变量 类型和变量 类型 C# 支持两种类型:“值类型”和“引用类型”。值类型包括简单类型(如 char、int 和 float 等)、枚举类型和结构类型。引用类型包括类 (Class)类 型、接口类型、委托类型和数组类型。 变量的类型声明 变量的类型声明 每个变量必须预先声明其类型。如 int a; int b = 100; float j = 4.5; string s1; 用 object 可以表示所有的类型。 预定义类型 下表列出了预定义类型,并说明如何使用。 类型 object 说明 所有其他类型的最终 基类型 字符串类型; 字符串是 Unicode 字符序列 8 位有符号整型 16 位有符号整型 32 位有符号整型 64 位有符号整型 示例 object o = null; 范围 string sbyte short int long string s = "hello"; sbyte val = 12; short val = 12; int val = 12; long val1 = 12; -128 到 127 -32,768 到 32,767 -2,147,483,648 2,147,483,647 -9,223,372,036,854,775,808 到 第1页 C#(WINFORM)学习 long val2 = 34L; 到 9,223,372,036,854,775,807 byte ushort 8 位无符号整型 16 位无符号整型 byte val1 = 12; ushort val1 = 12; uint val1 = 12; uint 32 位无符号整型 uint val2 = 34U; ulong val1 = 12; ulong val2 = 34U; ulong 64 位无符号整型 ulong val3 = 56L; ulong val4 = 78UL; float 单精度浮点型 float val = 1.23F;7 位 double val1 = 1.23; double 双精度浮点型 double val2 = ±5.0 × 10?324 ±1.7 × 10 308 0 到 255 0 到 65,535 0 到 4,294,967,295 0 到 18,446,744,073,709,551,615 ±1.5 × 10?45 ±3.4 × 10 38 到 到 4.56D;15-16 布尔型;bool 值或为 真或为假 字符类型;char 值是 一个 Unicode 字符 精确的小数类型, 具有 28 个有效数字 bool val1 = true; bool val2 = false; char val = 'h'; decimal val = bool char decimal DateTime ±1.0 × 10?28 ±7.9 × 10 28 到 1.23M;28-29 变量转换 简单转换: float f = 100.1234f; 可以用括号转换: short s = (short)f 也可以利用 Convert 方法来转换: string s1; s1=Convert.ToString(a); MessageBox.Show(s1); 常用 Convert 方法有: 第2页 C#(WINFORM)学习 C# Convert.ToBoolean Convert.ToByte Convert.ToChar Convert.ToDateTime Convert.ToDecimal Convert.ToDouble Convert.ToInt16 Convert.ToInt32 Convert.ToInt64 Convert.ToSByte Convert.ToSingle Convert.ToString Convert.ToUInt16 Convert.ToUInt32 Convert.ToUInt64 备注 Math 类 常用科学计算方法: C# Math.Abs Math.Sqrt Math.Ro

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧