Listview vs datagrid

前端 未结 2 666
有刺的猬
有刺的猬 2021-02-07 07:55

What are the main advantages of using a datagrid control over using a listview? When should each one be used?

相关标签:
2条回答
  • 2021-02-07 08:09

    I've abandoned the ListView for the DataGrid in .Net 4, since templating the columns is easier.

    Layout is also more sensible, and I don't need to remember to set the HorizontalContentAlignment to Stretch to get the cell contents to cover the cell. Another nice bit of functionality is edit templates on the DataGrid, which relieves me of having to use a CellTemplateSelector to get a different control when editing the cell.

    0 讨论(0)
  • 2021-02-07 08:23

    Some points to consider that Colin Eber have stated in DataGrid vs GridView discussion:

    • ListView (GridView) is a readonly control out-of-the-box.The standard solution would be to synchronise the list with a 'details view' comprised of textBoxes
    • The DataGrid allows in-place editing of data
    • The DataGrid performs transaction edits (the row is treated as an atom)
    • The DataGrid support auto-column generation
    • The DataGrid has a RowDetails element (if you like that sort of thing!)
    • The DatGrid supports pretty much everything the ListView does, multiple selection modes, styling, etc ...

    And another important one:

    • The DataGrid has build-in sorting support by clicking on column header. While add sorting to ListView/GridView is absolutely possible, I'd rather prefer to have such kind of things out-of-the-box in DataGrid.
    0 讨论(0)
提交回复
热议问题