WPF 中 ListView 和 DataGrid 的区别? [英] Difference between ListView and DataGrid in WPF?
问题描述
我必须从数据库中检索一些问题并将它们动态显示在用户屏幕上.我还需要在网格视图的列中添加一些控件,基本上是一个问题和答案的输入框.
I have to retrieve some questions from the database and display them on the user screen dynamically. I also need to add some controls in the columns of grid view, basically a question and input box for an answer.
请建议我应该使用哪个?ListView
还是 DataGrid
?
Please suggest which one should I use? ListView
or DataGrid
?
推荐答案
好吧,在 WPF 中,ListView
和 DataGrid
之间的区别只有一个.编辑.您需要编辑使用DataGrid
,否则使用ListView
.您也可以在 ListView
中进行编辑,但在 DataGrid
中构建更容易.否则,任何可以在DataGrid
中显示的内容,都可以在ListView
中显示.
Well, in WPF the difference between ListView
and DataGrid
is just one. Editing. You need editing use DataGrid
, otherwise use ListView
. You can edit in ListView
also but it is easier and build in DataGrid
. Otherwise, whatever can be displayed in DataGrid
, can be displayed in ListView
.
DataGrid
支持而 ListView
不支持的一件事是自动列生成.
One thing which DataGrid
supports and ListView
doesn't (out of the box) is automatic column generation.
您可以阅读这篇关于 CodeProject 的文章,以更好地理解DataGrid
以及 ListView
和 DataGrid
之间的主要区别.
You can read this article on CodeProject for a better understanding of DataGrid
and also about the major differences between ListView
and DataGrid
.
这篇关于WPF 中 ListView 和 DataGrid 的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!