Listview or Gridview in Windows Forms

Asked

Viewed 1,066 times

7

I’m studying about Windows Forms Aplication. I made a tutorial where Listview is used to display the data of a query according to the parameters passed.

But I noticed that you also have Gridview for us to use on Toolbox. And in this other tutorial, use Gridview to display search data.

My doubts are:

  1. What’s the difference between the two ?
  2. On what occasion to wear each ?
  3. One is better than the other ? Or are both good ?

2 answers

6

What’s the difference between the two?

ListView is a more complete component, with greater possibility of customization and support for native ordering. GridView is a simpler component, faster to use and requiring less configuration.

They both have:

  • Paging;
  • Editing;
  • Selection;
  • Template system (GridView is more limited).

ListView has the most:

  • Native ordination;
  • Grouping of items;
  • Enhanced layout extensibility.

On what occasion to wear each?

Use GridView for most tables, which does not require much configuration and requires less processing at the time of being generated.

Use ListView for a sophisticated view of your data source, or with more specific layout requirement.

Is one better than the other? Or are both good?

Each one meets a type of need. Measure this is the responsibility of the programmer.

5


I see the grid as a tabulated list of data that doesn’t talk all about itself - it usually requires a header (a form with the parent data of these records) and a summary.

Already the listview I see as a list of more complete objects (not necessarily with more information - maybe just the opposite), this list can have different views as the information about these objects that you want to have highlighted at that time.

Example: A list of files in a Windows folder

Objective: an overview of the folder

If your goal is to get an idea of the amount of files and space occupied by these files, you would probably want to list them in a grid, seeing in the header the folder path and in the summary the amount of files and the total space occupied.

The grid with the list of files in this case has a secondary function of offering an overview of the files that are there.

Goal: an analysis of the files that are in the folder

Now, your goal may also be the files themselves.

You may be wanting to understand things like: is this folder more for work or college documents? What types of files do I have here? The images that are here are private?

In this case you will probably want to list the files in a listview, with large icons that reveal the type and eventually a little about the content as well as the file name, and eventually you will want more details about a particular file and will click on it to see the size and date of creation without having to navigate to another form.

Completion

In the first case the focus is on the whole, and the list is only a part of this whole; then we use grid.

In the second case the focus is on the item, and the list allows us to switch between different views and reveals much about each item not only tabulatedly but also with the information arranged in the item itself; then we use listview.

  • So let’s say I have a student record, for example. And in this register I have information like: ID, name, father’s name, mother’s name, parent’s name, grade, year. And I had another table with the records of your (student’s) occurrences. Which of the two types would be the best to use ?

  • It depends on what the focus of this particular interaction is. My example suggests either grid or listview for the same type of records (files). So it’s not the guy who determines what to use. Let’s say a counselor will divide the students into classes according to the profile of each student - the focus is on the item (the student). Let’s say you’re looking at class data, which has a teacher, calendar, classroom and students - the focus is not on the items and students will be on a grid. In addition to the focus, it also counts the interaction you want to offer - if it can be as simple as possible, go grid in 1st place.

  • On the Grid, you can also make two clicks on the line ?

  • @Érikthiago Has yes. If you have problems trying to implement you can ask new questions.

  • Aah, great then. Thanks for the answer !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.