自動擷取和建立XML檔案的表列到DataGridView顯示和編輯

來源:互聯網
上載者:User

2013年11月21日→星座:天蠍座
二〇一三年十月十九
癸巳〖蛇〗癸亥月辛卯日甲午時
今屬:金;五行:水火金木;缺:土。
納音五行:長流水。
    
感恩節 彝族年 世界問候日 世界電視日

        private void 擷取檔案路徑匯入XML()        {            DataSet 資料集 = new DataSet();            OpenFileDialog 開啟檔案 = new OpenFileDialog();            開啟檔案.Filter = "XML檔案|*.xml;|所有檔案(*.*)|*.*";            if (開啟檔案.ShowDialog() == DialogResult.OK)            {                資料集.ReadXml(開啟檔案.FileName);                自定日曆.DataSource = null;                自定日曆.Columns.Clear();                自定日曆.Rows.Clear();                自定日曆.ReadOnly = false;                自定日曆.AllowUserToAddRows = true;                DataColumn[] 列集 = new DataColumn[資料集.Tables[0].Columns.Count];                資料集.Tables[0].Columns.CopyTo(列集, 0);                for (int 列 = 0; 列 != 列集.Length; 列++)                {                    DataGridViewTextBoxColumn 新列 = new DataGridViewTextBoxColumn();                    新列.HeaderText = 列集[列].ColumnName;                    新列.DataPropertyName = 列集[列].ColumnName;                    自定日曆.Columns.Add(新列);                }                BindingSource 資料來源 = new BindingSource();                資料來源.DataSource = 資料集.Tables[0];                自定日曆.DataSource = 資料來源;            }        }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.