private void dgvSeriesArticles_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (m_loading) { return; } Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); ArticlesSection section = config.GetSection("articleListing") as ArticlesSection; ArticleElement article = null; if (e.RowIndex < section.Articles.Count) { article = section.Articles[e.RowIndex]; } else { article = new ArticleElement(); } article.Name = Convert.ToString(dgvSeriesArticles.Rows[e.RowIndex].Cells[0].Value); article.Description = Convert.ToString(dgvSeriesArticles.Rows[e.RowIndex].Cells[1].Value); article.State = (ArticleState)Enum.Parse(typeof(ArticleState), Convert.ToString(dgvSeriesArticles.Rows[e.RowIndex].Cells[2].Value)); article.Sequence = Convert.ToInt32(dgvSeriesArticles.Rows[e.RowIndex].Cells[3].Value); config.Save(); }
private void ConfigurationExample_Load(object sender, EventArgs e) { ArticlesSection section = ConfigurationManager.GetSection("articleListing") as ArticlesSection; txtSeriesName.Text = section.Name; DataTable articles = new DataTable(); articles.Columns.Add("Name", typeof(string)); articles.Columns.Add("Description", typeof(string)); articles.Columns.Add("State", typeof(string)); articles.Columns.Add("Sequence", typeof(int)); foreach (ArticleElement article in section.Articles) { DataRow row = articles.NewRow(); row["Name"] = article.Name; row["Description"] = article.Description; row["State"] = article.State.ToString(); row["Sequence"] = article.Sequence; articles.Rows.Add(row); } m_loading = true; dgvSeriesArticles.DataSource = articles; }
private void txtSeriesName_TextChanged(object sender, EventArgs e) { if (m_loading) { return; } Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); ArticlesSection section = config.GetSection("articleListing") as ArticlesSection; section.Name = txtSeriesName.Text; config.Save(); }