
根据内容,我的意思是可能存在的一些纯文本.
@R_419_6120@ 按照Phillip的说法 – DataGrID通常是数据绑定的.下面是我的WPF DataGrID绑定到ObservableCollection< Personname>的示例.其中Personname由Firstname和Lastname(两个字符串)组成.DataGrID支持自动创建列,因此示例非常简单.您将看到我可以通过索引访问行,并使用与列名对应的属性名称获取该行中单元格的值.
namespace WpfApplication1{ /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); // Create a new collection of 4 names. nameList n = new nameList(); // Bind the grID to the List of names. dataGrID1.ItemsSource = n; // Get the first person by its row index. Personname firstPerson = (Personname) dataGrID1.Items.GetItemAt(0); // Access the columns using property names. DeBUG.Writeline(firstPerson.Firstname); } } public class nameList : ObservableCollection<Personname> { public nameList() : base() { Add(new Personname("Willa","Cather")); Add(new Personname("Isak","Dinesen")); Add(new Personname("Victor","Hugo")); Add(new Personname("Jules","Verne")); } } public class Personname { private string firstname; private string lastname; public Personname(string first,string last) { this.firstname = first; this.lastname = last; } public string Firstname { get { return firstname; } set { firstname = value; } } public string Lastname { get { return lastname; } set { lastname = value; } } }} 总结 以上是内存溢出为你收集整理的c# – WPF DataGrid:你如何获得单个单元格的内容?全部内容,希望文章能够帮你解决c# – WPF DataGrid:你如何获得单个单元格的内容?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)