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

namespace DataGrid_CS
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            #if DEBUG
                MinimizeBox = false;
            #else
                MinimizeBox = true;
            #endif
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                // Загружаем данные DataSet
                DataSet ds = new DataSet();
                ds.ReadXml(@"\Program Files\DataGrid_CS\artists.xml");
                grdArtists.DataSource = ds.Tables[0];
            }
            catch (Exception)
            {
                MessageBox.Show("Не могу загрузить данные в DataGrid!", this.Text);
            }

            // Устанавливаем стили
            DataGridTableStyle ts = new DataGridTableStyle();
            ts.MappingName = "Order";
            
            DataGridColumnStyle artistDate = new DataGridTextBoxColumn();
            artistDate.MappingName = "BirthDate";
            artistDate.HeaderText = "Дата рождения";
            ts.GridColumnStyles.Add(artistDate);

            DataGridColumnStyle artistName = new DataGridTextBoxColumn();
            artistName.MappingName = "ArtistName";
            artistName.HeaderText = "Артист";
            artistName.Width = this.Width - artistDate.Width - 35;
            ts.GridColumnStyles.Add(artistName);
           
            grdArtists.TableStyles.Add(ts);

            Cursor.Current = Cursors.Default;
        }
    }
}