Automatically get and CREATE table columns for XML files to DataGridView display and edit

Source: Internet
Author: User


November 21, 2013 → Constellation: Scorpio
October 2013 19
The Snake of the moon Sin Sing a Noon
This genus: gold; Five elements: hydrothermal Jin Mu; lack: soil.
Naishin Five elements: long running water.

World Television Day of the world Greeting Day of the Yi year

        private void Get file path import XML () {DataSet DataSet = new DataSet ();
            OpenFileDialog Open File = new OpenFileDialog (); Open the file.
            Filter = "XML file |*.xml;| all files (*.*) |*.*"; If (opens the file.) ShowDialog () = = DialogResult.OK) {DataSet. READXML (Opens the file.)
                FileName); Customize the calendar.
                DataSource = null; Customize the calendar.
                Columns.clear (); Customize the calendar.
                Rows.clear (); Customize the calendar.
                ReadOnly = false; Customize the calendar.
                Allowusertoaddrows = true; datacolumn[] Column set = new datacolumn[data set. Tables[0].
                Columns.count]; Data set. Tables[0].
                Columns.copyto (column set, 0); for (int column = 0; column!= column set. Length;
                    Column + +) {datagridviewtextboxcolumn new column = Datagridviewtextboxcolumn (); The new column. HeaderText = Column set [column].
                    ColumnName; The new column. datapropertyname = Column set [column].
                    ColumnName; Customize the calendar.
                Columns.Add (new column); } BindingSource Data Source = new BindingSource (); The data source. DataSource = DataSet.
                Tables[0]; Customize the calendar.
            DataSource = data source; }
        }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.