当前位置:编程学习 > C#/ASP.NET >>

关于using指令的疑问,求教!

已经using System.Windows.Forms了,为什么程序还出现如下错误呢?
错误 1 “System.Windows.Controls.DataGrid”不包含“DataSource”的定义,并且找不到可接受类型为“System.Windows.Controls.DataGrid”的第一个参数的扩展方法“DataSource”(是否缺少 using 指令或程序集引用?)
错误 2 “System.Windows.Controls.DataGrid”不包含“DataMember”的定义,并且找不到可接受类型为“System.Windows.Controls.DataGrid”的第一个参数的扩展方法“DataMember”(是否缺少 using 指令或程序集引用?)

VS2010 4.0FW 环境

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
//using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.Data.OleDb;




namespace ElevationCalculation
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.textBoxInput.Text = @"线路设计数据文件.xlsx";
        }

        private void buttonSelectInput_Click(object sender, RoutedEventArgs e)
        {
            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            this.openFileDialog1.Filter = "线路设计数据(xlsx)|*.xlsx";
            this.openFileDialog1.FileName = this.textBoxInput.Text;
            if (this.openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                this.textBoxInput.Text = this.openFileDialog1.FileName;
        }

        private void buttonReadInput_Click(object sender, RoutedEventArgs e)
        {
            string filePath = this.textBoxInput.Text;
            string strConn;
            strConn = @"Provider=Microsoft.Ace.OleDb.12.0;" +
            @"Data Source=filePath;" +
            @"Extended Properties=Excel 12.0;";

            OleDbConnection conn = new OleDbConnection(strConn);
            OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [施工右线坡度$]", strConn);
            DataSet myDataSet = new DataSet();
            myCommand.Fill(myDataSet);
            this.dataGrid1.DataSource = myDataSet;
            this.dataGrid1.DataMember = myDataSet.Tables[0].TableName;
        }

        private System.Windows.Forms.OpenFileDialog openFileDialog1;
    }
}
--------------------编程问答-------------------- 帮顶的 --------------------编程问答-------------------- 没有添加应用 即使你用了using  也没用 --------------------编程问答-------------------- 你可以参照2楼看看。 --------------------编程问答-------------------- 添加引用 -> .net -> winform
补充:.NET技术 ,  其他语言
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,