开发者

WPF GridView rows very small/not appearing when bound to DataTable

开发者 https://www.devze.com 2023-04-05 16:40 出处:网络
I\'m having trouble getting the data in a DataTable to show up in a GridView. When I use the 开发者_JAVA百科code below to set the ItemsSource to the Default view for the DataTable I\'ve populated, not

I'm having trouble getting the data in a DataTable to show up in a GridView. When I use the 开发者_JAVA百科code below to set the ItemsSource to the Default view for the DataTable I've populated, nothing seems to get added to the grid view. Quite a few rows do seem to appear, but they're very thing (only a few pixels high) and I can't seem to resize them to see if they've got any data in them, almost as though a new row's being created but it's blank. The column headers don't seem to show up either.

listView.View = new GridView();

listView.ItemsSource = dataTableSet.Tables[fileName].DefaultView;

Like I say the datatable's been populated and the scroll bar does appear when the ItemsSource is set to the data table, but I just can't see any of the data. Do I need to modify the default view of the datatable or something?

Thanks


You are creating a new GridView. It has no columns set up so it can't show anything.
I'm guessing its rows have an Height=Auto default, that would explain what you see.

The best solution would seem to create and design the GridView beforehand.

If you want auto-columns, maybe better use a DataGrid.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号