如何创建WPF中的DataTable? [英] How do you create a Datatable in wpf?

查看:2468
本文介绍了如何创建WPF中的DataTable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写在C#应用程序中使用WPF,我想知道你是怎么在WPF中创建数据表?这是一个非常愚蠢的问题,我知道,但它不会出现像我使用的是正确的引用数据表对象当我尝试创建它永远不会出现。我的参考资料如下:

 使用系统;
使用System.Collections.Generic;
使用System.Text;
使用System.Windows;
使用System.Windows.Controls的;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Shapes;
使用System.IO;
使用System.Linq的;
使用System.ComponentModel;
使用System.Data.Sql;
 

解决方案

下面是创建一个DataTable的方法...

 私人无效CreateDataTable()
    {
        System.Data.DataTable DT =新的DataTable(MyTable的);
        dt.Columns.Add(根据MyColumn的typeof(字符串));
        dt.Rows.Add(数据行);
    }
 

相关组件(如在解说确定HighCore)是System.Data这。如果不包含在您的引用,你可以通过添加引用上下文菜单中添加它。

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:

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;

解决方案

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.

这篇关于如何创建WPF中的DataTable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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