List <Control> allTextBoxControls; //Have autocomplete public EmployeeForm() { InitializeComponent(); //AutoComplete //-Initializing Controls (TextBox) allTextBoxControls = UtilWinforms.GetAllControlsOfType(this, typeof(TextBox)).ToList(); allEmployees = EmployeeDatabase.GetAllEmployees(); //Read table for updates //Textbox - Settings foreach (TextBox e in allTextBoxControls) { //Assign events e.KeyUp += new KeyEventHandler(txt_EnterKeyUp); //Assign a tag to all text boxes in form2 e.Tag = "Search"; } //Run AutoComplete UtilWinforms.UpdateAutoComplete(ref allTextBoxControls, ref allEmployees); }
public TimeSheetForm() { InitializeComponent(); allEmployees = EmployeeDatabase.GetAllEmployees(); List <Control> tempCells = UtilWinforms.GetAllControlsOfType(this, typeof(TextBox)).ToList(); foreach (TextBox e in tempCells) { //By default Cells (grid textboxes) do have null tags if (e.Tag == null) { allCells.Add(e); //Hint type of cells CheckForDummies(e); //Event handlers assignments e.Click += new EventHandler(cell_Click); e.Leave += new EventHandler(cell_Leave); e.Enter += new EventHandler(cell_Click); //Set autocomplete for all cells e.AutoCompleteMode = AutoCompleteMode.Suggest; e.AutoCompleteSource = AutoCompleteSource.CustomSource; AutoCompleteStringCollection data = new AutoCompleteStringCollection(); data.Add("0700"); data.Add("0800"); data.Add("0800"); data.Add("0900"); data.Add("0930"); data.Add("1030"); data.Add("1100"); data.Add("1200"); data.Add("1230"); data.Add("1400"); data.Add("1430"); data.Add("1630"); data.Add("1700"); e.AutoCompleteCustomSource = data; //Parsing cell to gather info WorkWeek.GetIndexes(ref grid); } else if (e.Tag.ToString() == "Search") { allTextBoxControlsSearch.Add(e); } } #region Initialize text boxes with name with autocomplete (reflection) //Populate first and last name text boxes autocomplete UtilWinforms.UpdateAutoComplete(ref allTextBoxControlsSearch, ref allEmployees); #endregion //Assign delegate events to all menu items foreach (ToolStripMenuItem item in menu.DropDownItems) { item.Click += new EventHandler(DropDownItemClicked); } //Event for print page, assigned to linklabel control lblPrint.LinkClicked += new LinkLabelLinkClickedEventHandler(lblPrint_LinkClicked); }