C#C
C#3y ago
tootall

❔ ObjectListView showing blank rows

Hi all. I'm new to C# and making VSTO addins, please bare with me!

I'm using the add-in control ObjectListView (https://objectlistview.sourceforge.net/cs/index.html) to create a list of categories as part of VSTO Outlook Add-in.

I've added the control to my form (a user control) and set the following properties:
  • View: List
  • Show Groups: False
  • Columns: One column added, AspectName "Category.Name" (also just "Name" was tried, without success).
Here is the code when the user control loads
  private void MyUserControl_Load(object sender, EventArgs e)
        {
            Categories categories = GetCategories();

            List<Category> myCategories = new List<Category>();

            foreach (Category c in categories)
            {
                myCategories.Add(c);
            }
           
            this.objectListView1.SetObjects(myCategories);
           
        }

I had thought that maybe the Objectlistview didn't like the default collection of the categories so that's why I made a new List<Category> collection

The category collection is obtained via
  public Categories GetCategories()
        {
            Categories categories = Globals.ThisAddIn.Application.Session.Categories;
            return categories;
        }


when I run this I get six empty rows, which matches the number of categories on the outlook account (see picture).

Not sure what I'm doing wrong, I followed the guide the best I could. The Category.Name method should be returning a string so I don't think that's the problem. Must be missing something obvious as this control is supposed to be easier to use than a listview.
image.png
Was this page helpful?