public SystemGenAndDisplay() { InitializeComponent(); VM = new StarSystemViewModel(); NameComboBox.DataSource = VM.StarSystems; NameComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentStarSystem, DataSourceUpdateMode.OnPropertyChanged); NameComboBox.DisplayMember = "Name"; NameComboBox.SelectedIndexChanged += (s, args) => NameComboBox.DataBindings["SelectedItem"].WriteValue(); AgetextBox.Bind(c => c.Text, VM, d => d.CurrentStarSystemAge); // Setup the stars Grid StarsDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; StarsDataGridView.RowHeadersVisible = false; StarsDataGridView.AutoGenerateColumns = false; StarsDataGridView.Bind(c => c.AllowUserToAddRows, VM, d => d.isSM); StarsDataGridView.Bind(c => c.AllowUserToDeleteRows, VM, d => d.isSM); StarsDataGridView.Bind(c => c.ReadOnly, VM, d => d.isNotSM); AddColumnsToStarDataGrid(); StarsDataGridView.DataSource = VM.StarsSource; StarsDataGridView.SelectionChanged += new EventHandler(StarsDataGridView_SelectionChanged); // Setup the Planet Data Grid PlanetsDataGridView.AutoGenerateColumns = false; PlanetsDataGridView.RowHeadersVisible = false; PlanetsDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; PlanetsDataGridView.Bind(c => c.AllowUserToAddRows, VM, d => d.isSM); PlanetsDataGridView.Bind(c => c.AllowUserToDeleteRows, VM, d => d.isSM); PlanetsDataGridView.Bind(c => c.ReadOnly, VM, d => d.isNotSM); AddColumnsToPlanetDataGrid(); PlanetsDataGridView.DataSource = VM.PlanetSource; PlanetsDataGridView.SelectionChanged += new EventHandler(StarADataGridView_SelectionChanged); }
private void ClearForm() { NametextBox.Clear(); AgetextBox.Clear(); Submitbutton.Enabled = false; }