コード例 #1
0
        private void ReadXmlFileAndBindToDataGrid()
        {
            string dataFilePath = AppConfig.dataFilePath;

            //
            // read data file
            //
            IDataService dataService = new XmlDataService(dataFilePath);

            _characters = dataService.ReadAll();

            //
            // bind list to DataGridView control
            //
            var bindingList = new BindingList <Character>(_characters);
            var source      = new BindingSource(bindingList, null);

            dataGridView_Characters.DataSource = source;

            //
            // configure DataGridView control
            //
            this.dataGridView_Characters.Columns["Id"].Visible            = false;
            this.dataGridView_Characters.Columns["ImageFileName"].Visible = false;
            this.dataGridView_Characters.Columns["Description"].Visible   = false;
        }
コード例 #2
0
 private void btn_exit_Click(object sender, EventArgs e)
 {
     try
     {
         IDataService XmlDataService = new XmlDataService(AppConfig.dataFilePath);
         XmlDataService.WriteAll(_characters);
     }
     catch (Exception)
     {
         throw;
     }
     this.Close();
 }