Search code examples
objectlistview

What's the proper way to edit text in objectlistview


I have an objectlistview with 4 columns and a dynamic number of rows, I'm struggling with programmable editing a cell text value, and optionally change the forecolor

I've read everything and anything that I could put my hands on, but couldn't find any valid and right to the point example on how to do it.

the ObjectListView is created this why

List<VideoItem> list = new List<VideoItem>();
foreach (dynamic item in VideoItems)
{
    list.Add(new VideoItem { Index = (int)item.index, OldName = (string)item.oldname, NewName = (string)item.newname });
}


olv1.AddObjects(list);

VideoItem class look like this

private class VideoItem
{
    public int Index;
    public string OldName;
    public string NewName;
}

enter image description here


Solution

  • but i need to programmably edit a cell text on event. I'm doing some logical operations on other cell at the end im storing the result to to cell next to it.

    You should be storing the result (making the change) to the underlying model object and then call RefreshObject(myModelObject);

    About the forcolor, i need to change only the cell I've changed

    "To change the formatting of an individual cell, you need to set UseCellFormatEvents to true and then listen for FormatCell events."

    Take a look at this.