How to add a new object to ObjectListView?

I tried the demo code in a demo project, but I cannot add a new item successfully. It just adds a new new NULL group and a NULL element. Please give me a simple code example to add a new element (text and image).

Thank!


Excuse me! I forgot this. This is the first time I participate in this site. I am using C #. And the code:

objectListView1.BeginUpdate();
objectListView1.AddObject(new string [] {"Hello","dfdsF" });
objectListView1.EndUpdate();

and

objectListView1.BeginUpdate();
OLVListItem item = new OLVListItem(new string [] {"Hello","dfdsF" });
objectListView1.Items.Add(item);
objectListView1.EndUpdate();

This is so different from ListView and EXListView, which I can define for text or image when creating a new item. But in ObjectListView I don't understand OBJECT?

I get ObjectListView anh, here is the demo code http://nchc.dl.sourceforge.net/project/objectlistview/objectlistview/v2.5/ObjectListViewFull-2.5.0.zip

+5
2

, , . , , ObjectListView.

SetObjects List<T>:

public Form1()
{
    InitializeComponent();
    this.objectListView1.SetObjects(haha.GET());
}

, haha, (Name Detail):

class haha
{
    string name;
    string detail;
    public haha(string name , string detail)
    {
        this.name = name;
        this.detail = detail;
    }

    public string Name
    {
        get { return name; }
        set { name = value; }
    }
    public string Detail
    {
        get { return detail; }
        set { detail = value; }
    } 

    static internal List<haha> GET()
    {
        haha item = new haha("zeko", "dunno");
        haha xx = new haha("sheshe", "dunno");
        haha ww = new haha("murhaf", "dunno");
        haha qq = new haha("soz", "dunno");
        haha ee = new haha("HELLO", "dunno");
        List<haha> x = new List<haha>();
        x.Add(item);
        x.Add(xx);
        x.Add(ww);
        x.Add(qq);
        x.Add(ee);
        return x;
    }
}

  • ShowGroups ObjectListView false
  • ; : Name Detail
  • , , . AspectName ,

enter image description here

:

enter image description here

AddObject(), , :

private void button1_Click(object sender, EventArgs e)
{
    haha newObject = new haha("memo","zezo");
    objectListView1.AddObject(newObject);
}

:)

+19

. ObjectListView.

myObjectListView.SetObjects(myListofEntityItems);

, . , AspectName .

0

All Articles