Пример #1
0
        private void tbtnAdd_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            var source = new DbSourceStruct {
                Type = e.ClickedItem.Text
            };

            using (var frm = new frmSourceEdit(source))
            {
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    var item = new TreeListItem();
                    lstProvider.Items.Add(item);
                    item.Group          = source.Type;
                    item.ImageIndex     = 0;
                    item.Tag            = source;
                    item.Cells[0].Value = source.Name;
                    item.Cells[1].Value = source.ConnectionString;

                    sources.Add(source);
                    SaveDataSources();

                    lstProvider.Grouping(true);
                }
            }
        }
Пример #2
0
        private void tbtnEdit_Click(object sender, EventArgs e)
        {
            if (lstProvider.SelectedItems.Count == 0)
            {
                return;
            }

            var item   = lstProvider.SelectedItems[0];
            var source = item.Tag as DbSourceStruct;

            using (var frm = new frmSourceEdit(source))
            {
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    item.Cells[0].Value = source.Name;
                    item.Cells[1].Value = source.ConnectionString;

                    SaveDataSources();
                }
            }
        }