Esempio n. 1
0
        public FormMain()
        {
            this.InitializeComponent();

            this.repositoryFactory = new RepositoryFactory(new RepositoryItemGrid());

            this.bindingNavigatorMain.BindingSource = this.bindingSourceMain;
            this.InitDataGridView();
            this.InitComboDataSource();
        }
Esempio n. 2
0
        private void InitComboDataSource()
        {
            this.comboBoxDataSource.Items.Add(
                new DictionaryEntry
                    {
                        Key = typeof(RepositoryItemGrid).Name.Replace(@"Repository", String.Empty),
                        Value = new RepositoryItemGrid()
                    });

            this.comboBoxDataSource.Items.Add(
                new DictionaryEntry
                {
                    Key = typeof(RepositoryDataTable).Name.Replace(@"Repository", String.Empty),
                    Value = new RepositoryDataTable()
                });

            this.comboBoxDataSource.DisplayMember = @"Key";
            this.comboBoxDataSource.ValueMember = @"Value";

            this.comboBoxDataSource.SelectedIndexChanged += (s, e) =>
                {
                    this.repositoryFactory =
                        new RepositoryFactory(
                            (IDataSourceRepository)((DictionaryEntry)this.comboBoxDataSource.SelectedItem).Value);

                    this.BindDataGridView();
                };

            this.comboBoxDataSource.SelectedIndex = 0;
        }