I'm loading a dropdown from the DB. When a selection is made I need to populate a listview from the DB. The items I'm pulling are a list of tables, views functions, etc. So I also need an icon for each object type. They'll be sorted by name initially, so ever item will have its icon but they won't be grouped together. Unfortunately I can't seem to find any good resources for loading a listview from a DB, much less adding icons like that.
Does anyone have a resource, or even a simple example?
Well... what you use depends on what functionality you need. ListView has a tremendous range of functionality, 5 different styles, etc. It's based on Windows Explorer.
It sounds like you want more of a ListBox than a ListView. So an UltraGrid with a single column would make sense. Or an UltraTree control and you could just turn off the expansion indicators. Both allow data binding.
The grid has filtering and the tree does not, though. So a grid seems like the way to go for what you need.
Actually, I've decided to use a 1-col grid. I think it'll have all the functionality I need and I should be able to style it to more or less look like a listbox.
What would you suggest as a alternative? I've got to choose from a dropdown and populate a bunch of other items to also be selected from. There could be up to 40k items in this list so it would be really nice if it also had an auto-complete feature that will filter the list based on what they're typing. Which control would you suggest for that? It's only going to have a single column of data cause it's gonna be used to fill a grid.
1. Because it's modeled after the inbox ListView control, which also does not support DataBinding. Which is not to say that we could not have added it as a feature - it's just not something that was determined to be important when the control was created. Other features were more important.
2. DataBindings is a property on Control. Since all controls derive from the Control class, all controls have a DataBindings property. But this is for simple binding - that is, binding a single property. It doesn't apply to complex binding, like binding to a list. You could bind to a single property using DataBindings and that would work, in theory, for some simple properties on the control. But it's not really very useful for a ListView.
Thanks for the response. I'll take a look at the article. I don't understand that though.
1. Why doesn't it support data binding? It's very common to load lists from bound sources.
2. If it doesn't support it, then why does it have a DataBindings method?