private void MenuItem_Form_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'restaurantManagementDataSet.MenuItem' table. You can move, or remove it, as needed. this.menuItemTableAdapter.Fill(this.restaurantManagementDataSet.MenuItem); this.menuTableAdapter1.Fill(this.restaurantManagementDataSet.Menu); dataGrid.DataSource = controller.ViewAll(); dataGrid.Columns["ID"].Width = 100; dataGrid.Columns["Name"].Width = 180; dataGrid.Columns["MenuName"].Width = 150; dataGrid.Columns["Describtion"].Visible = false; MenuTypeCombo.ValueMember = "ID"; IdText.Enabled = false; ClearData(); if (menu != null) { dataGrid.DataSource = controller.ViewItemsMenu(menu); MenuTypeCombo.SelectedIndex = MenuTypeCombo.FindStringExact(menu.Name); searchTextBox.Text = menu.Name; } else { dataGrid.DataSource = controller.ViewAll(); MenuTypeCombo.SelectedIndex = -1; } }
private void SelectRow() { if (dataGrid.SelectedRows.Count == 1) { var row = dataGrid.SelectedRows[0]; IdText.Text = row.Cells["ID"].Value.ToString(); NameText.Text = row.Cells["Name"].Value.ToString(); PriceText.Text = row.Cells["Price"].Value.ToString(); Descriptiontext.Text = row.Cells["Describtion"].Value.ToString(); string type = row.Cells["MenuName"].Value.ToString(); MenuTypeCombo.SelectedIndex = MenuTypeCombo.FindStringExact(type); saveBtn.Text = "Update"; } }