コード例 #1
0
        private void EditSelectedDatabaseItem(ListView focusedListView)
        {
            var datasource = (ArrangeableList <INamed>)focusedListView.Tag;

            var editForm = new frmAddEditDatabase();

            editForm.MethodToGetErrorsOnItemInformation = _databasesAppData.CheckForErrorsOnName;
            editForm.DatabaseInformation = (Database)focusedListView.SelectedItems[0].Tag;

            var dialogResult = editForm.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                var selectedIndices = focusedListView.SelectedIndices.Cast <int>().ToList();
                datasource.ReplaceAt(focusedListView.SelectedIndices[0], editForm.DatabaseInformation);
                PopulateListView(datasource, focusedListView, selectedIndices);
            }
        }
コード例 #2
0
        private void AddNewDatabaseItem(ListView focusedListView)
        {
            var addForm = new frmAddEditDatabase();

            addForm.MethodToGetErrorsOnItemInformation = _databasesAppData.CheckForErrorsOnName;
            var dialogResult = addForm.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                var databaseList = ((ArrangeableList <INamed>)_databasesAppData.Instances);
                if (databaseList == null)
                {
                    databaseList = new ArrangeableList <INamed>();
                    _databasesAppData.Instances = databaseList;
                }
                databaseList.Add(addForm.DatabaseInformation);

                var selectedIndices = focusedListView.SelectedIndices.Cast <int>().ToList();
                PopulateListView(databaseList, focusedListView, selectedIndices);
            }
        }