为每个listview项目赋予唯一的nr [英] Give each listview item unique nr

查看:78
本文介绍了为每个listview项目赋予唯一的nr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您查看图片 http://imageshack.us /f/190/sh*t34.png/ [ ^ ]

我尚未在listviewitem中创建任何ID

这是我的课程

http://imageshack.us/f/692/sh*t33.png/ [ ^ ]

在客户类中,我有

if you look picture http://imageshack.us/f/190/sh*t34.png/[^]

I have not created any ID in listviewitem

Here are my classes

http://imageshack.us/f/692/sh*t33.png/[^]

In Customer class i have

public int ID
{
    get
    {
        return id;
    }
    set
    {
        id = value;
    }
}



然后我想由CustomerManger对象确定


无论如何,我要怎么做才能使ID以100开头的ID,还可以理解是否已删除项目.



which i then wants to determine by a CustomerManger object


anyway what can i do to make an ID where i wants the ID to start with 100 and can also understand if item is deleted.

listviewitem = new ListViewItem(); //here should be the ID
listviewitem.SubItems.Add(contact.FirstName);
listviewitem.SubItems.Add(contact.LastName);
listviewitem.SubItems.Add(phone.Home);
listviewitem.SubItems.Add(phone.Mobile);
listviewitem.SubItems.Add(address.Country);
listviewitem.SubItems.Add(address.ZipCode);
listviewitem.SubItems.Add(address.City);
listviewitem.SubItems.Add(address.Street);
listviewitem.SubItems.Add(email.Personal);

this.listView1.Items.Add(listviewitem);

推荐答案

Shahin我不明白您的意思.但是我的老师希望我像我一样上不同的课,我认为这也是愚蠢的.我只想让ID从100开始,并为每个新项目添加+1.就这么简单
Shahin i dont understand what you mean. But my teacher wanted me to have diffrent classes like i have done, i think its stupid too. I want just want ID to start from 100 and add +1 for every new item. Simple as that


这篇关于为每个listview项目赋予唯一的nr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆