private void btnChangeDictionary_Click(object sender, EventArgs e) { using (var frm = new ChangeDictionaryForm()) { frm.ShowDialog(); if (frm.DialogResult == DialogResult.OK) { newDictionary = frm.GetSelectedDictionary(); tbDictionaryName.Text = newDictionary.DictionaryName; tbCategoryName.Text = newDictionary.CategoryName; } } }
public SelectedDictionary GetSelectedDictionary() { var row = dictGridView.SelectedRows[0].DataBoundItem; Type t = dictGridView.SelectedRows[0].DataBoundItem.GetType(); SelectedDictionary selectedDictionary = new SelectedDictionary() { Category_id = (int)t.GetProperty("Category_id").GetValue(row), CategoryName = (string)t.GetProperty("CategoryName").GetValue(row), DictionaryName = (string)t.GetProperty("FriendlyName").GetValue(row), Dictionary_id = (int)t.GetProperty("Dictionary_id").GetValue(row) }; return(selectedDictionary); }