C#listView的View属性为Tile时,怎么为他添加项 10
4个回答
展开全部
那个ico的图片你可以在你安装程序的盘符,随便搜一个后缀名ico的图片用
public Form1()
{
// Initialize myListView.
ListView myListView = new ListView();
myListView.Dock = DockStyle.Fill;
myListView.View = View.Tile;
// Initialize the tile size. myListView.TileSize = new Size(400, 45);
// Initialize the item icons.
myImageList = new ImageList();
using (Icon myIcon = new Icon("VIDEO.ico"))
{
myImageList.Images.Add(myIcon);
}
myImageList.ImageSize = new Size(32, 32);
myListView.LargeImageList = myImageList;
// Add column headers so the subitems will appear. myListView.Columns.AddRange(new ColumnHeader[] { new ColumnHeader(), new ColumnHeader(), new ColumnHeader() });
// Create items and add them to myListView.
ListViewItem item0 = new ListViewItem(new string[]
{"Programming Windows",
"Petzold, Charles",
"1998"}, 0);
ListViewItem item1 = new ListViewItem(new string[]
{"Code: The Hidden Language of Computer Hardware and Software",
"Petzold, Charles",
"2000"}, 0);
myListView.Items.AddRange(
new ListViewItem[] { item0, item1});
// Initialize the form.
this.Controls.Add(myListView);
this.Size = new System.Drawing.Size(430, 330);
this.Text = "ListView Tiling Example";
}
public Form1()
{
// Initialize myListView.
ListView myListView = new ListView();
myListView.Dock = DockStyle.Fill;
myListView.View = View.Tile;
// Initialize the tile size. myListView.TileSize = new Size(400, 45);
// Initialize the item icons.
myImageList = new ImageList();
using (Icon myIcon = new Icon("VIDEO.ico"))
{
myImageList.Images.Add(myIcon);
}
myImageList.ImageSize = new Size(32, 32);
myListView.LargeImageList = myImageList;
// Add column headers so the subitems will appear. myListView.Columns.AddRange(new ColumnHeader[] { new ColumnHeader(), new ColumnHeader(), new ColumnHeader() });
// Create items and add them to myListView.
ListViewItem item0 = new ListViewItem(new string[]
{"Programming Windows",
"Petzold, Charles",
"1998"}, 0);
ListViewItem item1 = new ListViewItem(new string[]
{"Code: The Hidden Language of Computer Hardware and Software",
"Petzold, Charles",
"2000"}, 0);
myListView.Items.AddRange(
new ListViewItem[] { item0, item1});
// Initialize the form.
this.Controls.Add(myListView);
this.Size = new System.Drawing.Size(430, 330);
this.Text = "ListView Tiling Example";
}
参考资料: http://msdn.microsoft.com/en-us/library/s8z85th0.aspx
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
属性里面找:Items---- 集合,在里面添加就可以了
也可在后台中添加,使用ListView1.Items.Add()方法
也可在后台中添加,使用ListView1.Items.Add()方法
追问
listView里面怎么添加子项啊
追答
在Items---- 集合,里面点 添加,就会出现ListViewItem,。在右面属性的:数据-集合,可继续添加下一级的项
下面那个应该是用DataList来实现的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
具体看我给你的参考资料的链接,我的账号没能提交答案,只能换别人的账号告诉你了,哈哈
参考资料: http://msdn.microsoft.com/en-us/library/s8z85th0.aspx
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询