wpf 你如何在wpf中创建数据表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19253459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you create a Datatable in wpf?
提问by user2859487
I'm writing an application in c# using wpf and i was wondering how do you create a data table in wpf? This is a really dumb question, i'm aware, but it doesn't appear like i'm using the correct references as the data table object never appears when i try to create it. My references are as follows:
我正在使用 wpf 在 c# 中编写一个应用程序,我想知道如何在 wpf 中创建数据表?这是一个非常愚蠢的问题,我知道,但它看起来不像我使用了正确的引用,因为当我尝试创建数据表对象时,它永远不会出现。我的参考资料如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using System.Linq;
using System.ComponentModel;
using System.Data.Sql;
回答by Gayot Fow
Here's a method that creates a DataTable...
这是一个创建数据表的方法......
private void CreateDataTable()
{
System.Data.DataTable dt = new DataTable("MyTable");
dt.Columns.Add("MyColumn", typeof (string));
dt.Rows.Add("row of data");
}
The relevant assembly (as identified by HighCore in the commentary) is System.Data. If it is not included in your references, you can add it via the 'add reference' context menu.
相关程序集(由 HighCore 在评论中标识)是 System.Data。如果它未包含在您的参考文献中,您可以通过“添加参考文献”上下文菜单添加它。

