基本信息
源码名称:listview设置不同图标
源码大小:0.01M
文件格式:.rar
开发语言:C#
更新时间:2019-05-08
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 20 元×
微信扫码支付:20 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using OAKControls;
namespace CSListView
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private OAKListView listView1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader5;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.Button button1;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.listView1 = new OAKControls.OAKListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4,
this.columnHeader5});
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(8, 8);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(496, 336);
this.listView1.TabIndex = 0;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Width = 100;
//
// columnHeader2
//
this.columnHeader2.Width = 100;
//
// columnHeader3
//
this.columnHeader3.Width = 100;
//
// columnHeader4
//
this.columnHeader4.Width = 100;
//
// columnHeader5
//
this.columnHeader5.Width = 92;
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// button1
//
this.button1.Location = new System.Drawing.Point(8, 352);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(172, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Click to add image on SubItems";
this.button1.Click = new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(512, 387);
this.Controls.Add(this.button1);
this.Controls.Add(this.listView1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "Form1";
this.Text = "OAK ListView";
this.Load = new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
listView1.SmallImageList = imageList1;
listView1.FullRowSelect = true;
listView1.GridLines = true;
listView1.View = View.Details;
for(int I=0;I<=15;I )
{
ListViewItem lvi = new ListViewItem(new string[]{"aaaaa","bbbb","cccc","dddd","eeee","ffff","gggg","hhhh"});
lvi.ImageIndex = 1;
listView1.Items.Add(lvi);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
for(int x=0;x<=listView1.Items.Count;x )
{
for(int I=0;I<listView1.Columns.Count;I )
{
OAKListView.LV_ITEM lvi = new OAKListView.LV_ITEM();
// Row
lvi.iItem = x;
// Column
lvi.iSubItem = I;
lvi.pszText = "OAKListView-" I.ToString();
lvi.mask = OAKListView.LVIF_IMAGE | OAKListView.LVIF_TEXT;
// Image index on imagelist
lvi.iImage = I;
OAKListView.SendMessage(listView1.Handle, OAKListView.LVM_SETITEM, 0, ref lvi);
}
}
MessageBox.Show("Tchanannnnn....", "OAKListView", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
}
}
}