private void btnAdd_Click(object sender, EventArgs e) { int selectedIdx = cmbTemplateGroup.SelectedIndex; FormAddCodeTemplate frm = new FormAddCodeTemplate(); frm.ShowDialog(); if (frm.CodeTemplate != null) { List <CodeTemplate> list = GetSelectedTemplateGroup().CodeTemplateList; list.Add(frm.CodeTemplate); SaveCodeTemplateGroups((List <CodeTemplateGroup>)cmbTemplateGroup.DataSource); LoadCmbTemplateGroups(); cmbTemplateGroup.SelectedIndex = selectedIdx; DisplaySelectedTemplateGroup(); } }
private void btnEdit_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows.Count > 0) { CodeTemplate codeTemplate = (CodeTemplate)this.dataGridView1.SelectedRows[0].DataBoundItem; string templateName = codeTemplate.TemplateName; //TextEditor.TextEditorForm frm = new TextEditor.TextEditorForm(); //frm.Code = codeTemplate.TemplateCodePlain; //frm.ShowDialog(); FormAddCodeTemplate frm = new FormAddCodeTemplate(); frm.CodeTemplate = codeTemplate; frm.ShowDialog(); if (frm.IsCanceled == false) { codeTemplate = frm.CodeTemplate; UpdateCodeTemplate(codeTemplate, templateName); DisplaySelectedTemplateGroup(); this.dataGridView1.Refresh(); } } }