/// <summary> /// Lägger till en DataGridView i TabControlern /// </summary> /// <param name="tabControl1"></param> /// <param name="listViewDivers"></param> /// <param name="_diveNo"></param> /// <param name="_diveName"></param> /// <param name="_dataGridViewList"></param> /// <param name="DiveCount_numericUpDown"></param> /// <param name="panel1"></param> public static void AddDataGridViewToTabControl(TabControl tabControl1, ListView listViewDivers, AutoCompleteStringCollection _diveNo, AutoCompleteStringCollection _diveName, List <DataGridView> _dataGridViewList, NumericUpDown DiveCount_numericUpDown, Panel panel1) { string[] row = new string[] { "A", "1", "Dummy Dive" }; tabControl1.TabPages.Clear(); if (listViewDivers.CheckedItems.Count > 0) { panel1.Visible = true; tabControl1.Visible = true; //antal tabbar for (int i = 0; i < listViewDivers.CheckedItems.Count; i++) { //om det har lagts till en ny hoppare skapas en ny DataGridView if (listViewDivers.CheckedItems.Count > _dataGridViewList.Count) { DataGridView newDataGrid = NewEventPresenter.GetNewDataGridView(_diveNo, _diveName, tabControl1); newDataGrid.Dock = DockStyle.Fill; _dataGridViewList.Add(newDataGrid); } _dataGridViewList[i].Columns[2].Width = tabControl1.Width - (51 + 55 + 55); //DataGridViewens tag är den samma som Diverns ID _dataGridViewList[i].Tag = listViewDivers.CheckedItems[i].SubItems[4].Text; //antal rader if (_dataGridViewList[i].RowCount <= Int32.Parse(DiveCount_numericUpDown.Value.ToString())) //om det är mindre rader än NumericUpDown { for (int j = _dataGridViewList[i].RowCount; j < Int32.Parse(DiveCount_numericUpDown.Value.ToString()); j++) { _dataGridViewList[i].Rows.Add(row); _dataGridViewList[i].Rows[j].HeaderCell.Value = String.Format("{0}", j + 1); } } else if (_dataGridViewList[i].RowCount > Int32.Parse(DiveCount_numericUpDown.Value.ToString())) //om det är fler rader än NumericUpDown { for (int j = _dataGridViewList[i].RowCount; j > Int32.Parse(DiveCount_numericUpDown.Value.ToString()); j--) { _dataGridViewList[i].Rows.Remove(_dataGridViewList[i].Rows[j - 1]); } } _dataGridViewList[i].Visible = true; string title = listViewDivers.CheckedItems[i].Text; TabPage newTab = new TabPage(title); newTab.Name = i.ToString(); newTab.Tag = listViewDivers.CheckedItems[i].SubItems[4].Text; tabControl1.TabPages.Add(newTab); newTab.Controls.Add(_dataGridViewList[i]); listViewDivers.Focus(); } } else { panel1.Visible = false; tabControl1.Visible = false; } }
private void listViewDivers_ItemChecked(object sender, ItemCheckedEventArgs e) { CheckIfSubmitButtonBeEnable(); NewEventPresenter.AddDataGridViewToTabControl(tabControl1, listViewDivers, _diveNo, _diveName, _dataGridViewList, DiveCount_numericUpDown, panel1); PanelDrawer.Colorize(this); //lägger till en eventhandler till varje DataGridView for (int i = 0; i < _dataGridViewList.Count; i++) { _dataGridViewList[i].EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(DiveTypeInput_dataGridView_EditingControlShowing); _dataGridViewList[i].CellEndEdit += new DataGridViewCellEventHandler(DataGridViewDives_CellEndEdit); _dataGridViewList[i].CellBeginEdit += new DataGridViewCellCancelEventHandler(DataGridViewDives_CellBeginEdit); } }
private void DiveTypeInput_dataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (((DataGridView)sender).CurrentCell.ColumnIndex == 0) { ComboBox cb = e.Control as ComboBox; if (cb != null) { //lägger till en Eventhandler på Position comboboxen cb.SelectionChangeCommitted -= new EventHandler(DataGridViewPositionSelectionChangeCommitted); cb.SelectionChangeCommitted += new EventHandler(DataGridViewPositionSelectionChangeCommitted); } } NewEventPresenter.AddAutoCompleteToDataGridView(_dataGridViewList, tabControl1, e, _diveNo, _diveNoReadOnly, _diveName, _diveNameReadOnly, groupBoxDisciplin); }
public FormNewEvent() { InitializeComponent(); PanelDrawer.Colorize(this); //fyller listorna med dommare och hoppare NewEventPresenter.FillListViewWithDivers(radioButtonMale, radioButtonFemale, listViewDivers); NewEventPresenter.FillListViewWithJudges(listViewJudge); listViewDivers.ItemDrag += listViewDivers_ItemDrag; listViewDivers.DragEnter += listViewDivers_DragEnter; listViewDivers.DragDrop += listViewDivers_DragDrop; listViewDivers.AllowDrop = true; //hämtar autocomplete listorna från databasen Database.GetAutoCompleteListsFromDatabase(_diveNo, _diveName); Database.GetAutoCompleteListsFromDatabase(_diveNoReadOnly, _diveNameReadOnly); }
private void DiveCount_numericUpDown_ValueChanged(object sender, EventArgs e) { NewEventPresenter.AddDataGridViewToTabControl(tabControl1, listViewDivers, _diveNo, _diveName, _dataGridViewList, DiveCount_numericUpDown, panel1); PanelDrawer.Colorize(this); }
private void listViewDivers_ColumnClick(object sender, ColumnClickEventArgs e) { NewEventPresenter.FillListViewWithDivers(radioButtonMale, radioButtonFemale, listViewDivers, e.Column); }
private void RemoveDiverToolStripMenuItem_Click(object sender, EventArgs e) { Database.RemoveDiver(Int32.Parse(selectedItem.SubItems[4].Text)); NewEventPresenter.FillListViewWithDivers(radioButtonMale, radioButtonFemale, listViewDivers); }
//autocomplete private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { NewEventPresenter.AddAutoCompleteToDataGridView(_dataGridViewList, tabControl1, e, _diveNo, _diveNoReadOnly, _diveName, _diveNameReadOnly, groupBoxDisciplin); PanelDrawer.Colorize(this); }
//uppdaterar listViewDivers när användaren väljer mellan Male och Female private void radioButtonMale_CheckedChanged(object sender, EventArgs e) { NewEventPresenter.FillListViewWithDivers(radioButtonMale, radioButtonFemale, listViewDivers); }
private void newJudgeSubmit_Click(object sender, EventArgs e) { NewEventPresenter.AddNewJudge(newJudgeName, listViewJudge); }
private void newJudgeName_Enter(object sender, EventArgs e) { NewEventPresenter.ResetTextBox(newJudgeName); }
private void AddNewDiver_Click(object sender, EventArgs e) { NewEventPresenter.AddNewDiver(newDiverSelectGender, newDiverName, newDiverAge, newDiverCountry, listViewDivers, radioButtonMale, radioButtonFemale); }
private void textBox5_Enter(object sender, EventArgs e) { NewEventPresenter.ResetTextBox(newDiverAge); }
private void textBox6_Enter(object sender, EventArgs e) { NewEventPresenter.ResetTextBox(newDiverCountry); }
//Skapar ett nytt event när användaren klickar på "Klar" i fönstret "FormNewEvent" private void btnSubmit_Click(object sender, EventArgs e) { NewEventPresenter.AddNewEventToDatabase(EventName_textBox, EventLocation_textBox, dateTimePicker1, DiveCount_numericUpDown, radioButton1meter, radioButton3meter, radioButton5meter, radioButton7meter, radioButton10meter, radioButtonSingle, radioButtonSync, radioButtonMale, radioButtonFemale, listViewDivers, listViewJudge, successfully, errorlabel, _dataGridViewList); }