你如何在wpf中创建数据表? [英] How do you create a Datatable in wpf?

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

问题描述

我正在使用 wpf 在 c# 中编写一个应用程序,我想知道如何在 wpf 中创建数据表?这是一个非常愚蠢的问题,我知道,但它看起来不像我使用了正确的引用,因为当我尝试创建数据表对象时,它永远不会出现.我的参考资料如下:

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;

推荐答案

这里有一个创建 DataTable 的方法...

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");
    }

相关程序集(由 HighCore 在评论中标识)是 System.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中创建数据表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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