如何使用C#从WPF中的DataGrid读取数据 [英] how to read data from datagrid in wpf using c#

查看:291
本文介绍了如何使用C#从WPF中的DataGrid读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
当我们在Windows应用程序中读取==>时,如何使用c#按行从wpf中的datagrid中读取数据?

Hello,
How can i read data from datagrid in wpf using c# rowwise ,as we read in windows application like =>

dataGridview1.Rows[i].Cells[1].Value.ToString()

推荐答案

您通常不会在WPF中读取此类数据.理想的方法是通过已绑定到数据网格的集合读取数据. WPF DataGrid实用示例 [此处 [
You generally don''t read data like this in WPF. The ideal way is to read data through the collection that has been bound to the datagrid. WPF DataGrid Practical Examples[^] should give you an idea.

However, something like the VisualTreeHelper class can help you access the rows and columns of a datagrid (as here[^]). This is not recommended though.


WPF Datagrid读取单元格值
读取WPF DataGrid中的单元格值?

但是最标准的方法是开始学习MVVM
WPF/MVVM快速入门指南(好的文章)
WPF Datagrid read a cell value
Reading a cell value in a WPF DataGrid?

But the most standard way is starting to learn MVVM
WPF/MVVM Quick Start Tutorial (Good Article)


这篇关于如何使用C#从WPF中的DataGrid读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆