ListView or GridView in Windows Forms

7

I am studying about Windows Forms Application . I did a tutorial where the ListView is used to display the data of a search according to the parameters passed.

But I noticed that there is also GridView to use in the toolbox. And in this other tutorial , the GridView to display the search data.

My questions are:

  • What's the difference between the two?
  • When to use each one?
  • Is one better than the other? Or are both good?
  • asked by anonymous 29.04.2015 / 22:05

    2 answers

    4

    I see the grid as a tabulated list of data that does not speak all about itself - usually requires a header (a form with the parent data of these records) and a summary.

    In the listview I see as a list of more complete objects (not necessarily with more information - maybe just the opposite), this list may have different views depending on the information about these objects that you want to have highlighted at that moment. / p>

    Example: A list of files in a Windows folder

    Purpose: 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 on a grid, seeing in the header the path of the folder and in the table of contents the number of files and the space total busy.

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

    Purpose: An analysis of the files that are in the

    Now, your goal can also be the files themselves.

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

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

    Conclusion

    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 you to switch between different views and reveals a lot about each item not only in tabular form but also with the information arranged in the item itself; then we use listview.

        
    29.04.2015 / 23:07
    5

    What is the difference between the two?

    ListView is a more complete component, with greater possibility of customizations and support to native ordering. GridView is a simpler, faster-to-use component that requires less configuration.

    Both have:

    • Paging;
    • Editing;
    • Selection;
    • Templates System ( GridView is more limited).

    ListView has more:

    • Native ordering;
    • Item grouping;
    • Enhanced layout extensibility.

    On which occasion do you use each?

    Use GridView for most tables, which does not require much configuration and requires less processing at the time it is 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 meets a type of need. Measuring this is up to the programmer.

        
    29.04.2015 / 22:36