private void SetTextBoxes() { IdTextBox.Text = IdListBox.GetItemText(IdListBox.SelectedItem); CategoryTextBox.Text = CategoryListBox.GetItemText(CategoryListBox.SelectedItem); NameTextBox.Text = NameListBox.GetItemText(NameListBox.SelectedItem); PriceTextBox.Text = PriceListBox.GetItemText(PriceListBox.SelectedItem); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //populate ItemsInCatalogueListBox var populateItemsInCatalogueListBox = context.StationeryCatalogues.Select(x => x.Description).ToList(); ItemsInCatalogueListBox.DataSource = populateItemsInCatalogueListBox; ItemsInCatalogueListBox.DataBind(); //populate SupplierDDL List <String> supList = new List <String>(); supList = context.Suppliers.Select(x => x.SupplierName).ToList(); SupplierDDL.DataSource = supList; SupplierDDL.DataBind(); //populate CategoryListBox var populateCatInCatalogueListBox = context.StationeryCatalogues.Select(x => x.Category).Distinct().ToList(); CategoryListBox.DataSource = populateCatInCatalogueListBox; CategoryListBox.DataBind(); //allow user to choose the 1st day of the month even if 36month ago the cut // off was eg: 4th var minDate = DateTime.Now.AddMonths(-36); var firstDayOfMonth = new DateTime(minDate.Year, minDate.Month, 1); //set the textbox date FromDate.Attributes["min"] = firstDayOfMonth.ToString("yyyy-MM-dd"); FromDate.Attributes["max"] = DateTime.Now.ToString("yyyy-MM-dd"); EndDate.Attributes["min"] = firstDayOfMonth.ToString("yyyy-MM-dd"); EndDate.Attributes["max"] = DateTime.Now.ToString("yyyy-MM-dd"); } }
private void CategoryListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { CategoryListBox.ScrollIntoView(e.AddedItems[0]); } }
private void Filter_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Down) { U.SelectedIndexSafety(ListBox, 0, true); return; } if (Filter.Text == "" && e.KeyCode == Keys.Left) { CategoryListBox.Focus(); return; } }
private void LoadCategories() { DBRequests.MakeRequest(DBRequests.LoadCategories(), (connection, sqlCommand) => { using (var reader = sqlCommand.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { _categories.Add(new TextInstance { Name = reader.GetString(0), ID = reader.GetInt32(1) }); } } CategoryListBox.Refresh(); } }); }
private void ListBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { SelectButton_Click(null, null); return; } if (e.KeyCode == Keys.Up && this.ListBox.SelectedIndex == 0) { Filter.Focus(); return; } if (e.KeyCode == Keys.Back) { Filter.Focus(); return; } if (e.KeyCode == Keys.Left) { CategoryListBox.Focus(); return; } }