❔ 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 I had thought that maybe the
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 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
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.16 Replies
List(either non-generic or genetic types) don't notify the UI that the property has changed. Try using
ObservableCollection
Full disclosure, I'm new at this as well and I've been studying this the past few hours 😆
Alternatively you might be able to useINotifyPropertyChanged
but an ObservableCollection might be easier.thanks for the reply! so you're suggesting using
ObservableCollection
in place of List
?Yeah, give that a shot. They have the same interface so they are interchangeable.
yea I did try it right now, same result, six blank rows 🙁
I should probably just try this out with a simple program and class just to see if I can get it to work that way.
How are you binding the data?
with this control you should just need to put the name of the property or method of the object into the column editor in the IDE. It generates the row directly from the object.
(if I understand what your asking!)
see here:
https://objectlistview.sourceforge.net/cs/gettingStarted.html#:~:text=The%20first%20configuration,properties%20at%20once).
I'm not sure. Can I see the source code? I might be able to get a better idea on what you're working with
There's really not much more than what I've shown you
Do you want me to just copy/paste it here?
Place it here: https://paste.mod.gg/
BlazeBin
A tool for sharing your source code with the world!
BlazeBin - lempulpxncoa
A tool for sharing your source code with the world!
Pretty cool stuff. I think you might be missing the binding. Check out the link below. They lead to the same page but different sections. I would look into Data Binding to make sure that the data is being passed to the Designer.
https://learn.microsoft.com/en-us/visualstudio/vsto/walkthrough-simple-data-binding-in-vsto-add-in-project?view=vs-2022&tabs=csharp#:~:text=new%20System.Windows.Forms.BindingSource
https://learn.microsoft.com/en-us/visualstudio/vsto/walkthrough-simple-data-binding-in-vsto-add-in-project?view=vs-2022&tabs=csharp#:~:text=Bind%20the%20content%20control%20to%20AdventureWorksLTDataSet%20by%20using%20the%20BindingSource.%20For%20C%23%20developers%2C%20add%20two%20event%20handlers%20for%20the%20Button%20controls.
Walkthrough: Simple data binding in VSTO Add-in project
Learn how you can add controls to a Microsoft Word document and bind the controls to data at run time.
thanks I'll check it out when I have a minute
well this very simple test worked no problem so I guess it has something to do with the
Category
object or collection thereof
Ohh sweet! Great job!
Let's not break out the champagne yet! I still need to find a solution for the actual implementation!
A further update on this - The "Category" class appears to be an interface of an interface. using the
.GetType()
for an item of the Categories collection returns System.__ComObject
, perhaps this is why it returns a blank string?
If I create a simple class with a single string property and then take the Category.Name
and save it the new class Name
the objectlistview will display it.
At this point I feel like I just need to create my own class and copy over the relevant information from each Category and use that instead. A bit of a PITA if I have to go back and forth between the Outlook category collection and my own.Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.