Mike
Mike

Reputation:

What winforms control should I use to display a table of search results returned from LINQ?

What control should I use when wanting to display a list of record information (Name, ID #, date)? It is about 5 small columns, and I'll have many rows returned.

I'm using LINQ to grab the records I need from the database and have it currently in an IQueryable.

Can anyone suggest what WinForms control I should be using in this case (ListView, DataGridView, ListBox?

What is the standard for this use case?

Upvotes: 1

Views: 474

Answers (2)

Niranjan
Niranjan

Reputation: 76

ListBox

This is very crude type of UI control. There are limitations on the operations you could do with column header, selected item etc.

e.g. user cannot resize the columns, cannot easily highlight specific items

I would use it for quickest implementation for data that has fixed width with no further customizations needed. e.g. select an option from a list

GridViewControl

This would offer great deal of flexibility and customization if you need it. It would be meaningless to explain all features here without knowing the exact context. However the default look is not very good. You need to customize it. Memory consumption and performance is OK for large data set. Not to worry much.

ListView

No data binding available. So you need to write some code. However the default look is appealing and the features are user friendly. It is also great for large data sets. I would always prefer this for it's standard look and use it to show read-only data.

The simplest way is to use DataGridView. If you strive for user-friendly UI, go for ListView.

Upvotes: 0

Tim Jarvis
Tim Jarvis

Reputation: 18815

Its really up to how you would like to display the data, if you want to bind the data you could use the datagridview or even just a datagrid. Another option would be to use the new DataRepeater control. You can bind your linq resultset to a BindingSource then bind the BindingSource to the grid/repeater.

The other options are also ok, in fact I always use a list view if I want to display grouped data, I think it looks good. The downside is that you need to populate listviews manually (not really that big of a deal IMO). One other thing to note is that ListViews also have a virtual mode which is ideal for large result sets, but, of course the rule about avoiding dumping large resultsets into gui widgets still applies (that is, avoid it with good filtering at the source if possible)

Upvotes: 1

Related Questions