0

I need to bind several properties from an Invoice table in a database to a ListView control.

For example, a row in my Invoices table might look like this:

| InvoiceId | VendorID | InvoiceNumber | InvoiceDate | InvoiceTotal |
|    100    |   10     |    909090     | 2008-09-18  |  23.95       |

And I want the properties "InvoiceDate" and "InvoiceTotal" to display in a ListView control, and have the user press a button to see a new form showing a more extensive set of details for this table row.

This is something I've done previously quite easily with databinding in Windows Phone / WPF, but what's the best way to do this in winforms?

My current solution is to add new ListViewItem(s) to the ListView control in a loop, where each ListViewItem's subitems has the properties from the Invoice row that I want it to display. This displays them just fine, but it means the ListView control doesn't really keep track of the Invoice items, so I can't easily pass the correct Invoice item (or Invoice primary key) to the new form when the user presses the button.

Any suggestions?

0

1 Answer 1

2

ObjectListView (an open source wrapper around a .NET ListView) adds data binding (plus lots of other neat features) to the .NET ListView. See this recipe for data binding.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.