private void EditFormMsg(int column_index) { if (this.dgvMsg.Rows[this.dgvMsg.CurrentCell.RowIndex].Tag is D_msg) { this.FormEditItemF8(); int row_index = this.dgvMsg.CurrentCell.RowIndex; CustomDateTimePicker inline_date = new CustomDateTimePicker(); inline_date.Name = "inline_date"; inline_date.BorderStyle = BorderStyle.None; inline_date.Read_Only = false; inline_date.textBox1.GotFocus += delegate { this.current_focused_control = inline_date; }; CustomTextBox inline_name = new CustomTextBox(); inline_name.Name = "inline_name"; inline_name.BorderStyle = BorderStyle.None; inline_name.Read_Only = false; inline_name.MaxChar = 3; inline_name.textBox1.GotFocus += delegate { this.current_focused_control = inline_name; }; CustomTextBox inline_desc = new CustomTextBox(); inline_desc.Name = "inline_desc"; inline_desc.BorderStyle = BorderStyle.None; inline_desc.Read_Only = false; inline_desc.MaxChar = 100; inline_desc.textBox1.GotFocus += delegate { this.current_focused_control = inline_desc; }; inline_desc.textBox1.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { this.toolStripSave.PerformClick(); } }; this.dgvMsg.Parent.Controls.Add(inline_date); this.dgvMsg.Parent.Controls.Add(inline_name); this.dgvMsg.Parent.Controls.Add(inline_desc); inline_date.TextsMysql = ((D_msg)this.dgvMsg.Rows[row_index].Tag).date; inline_name.Texts = ((D_msg)this.dgvMsg.Rows[row_index].Tag).name; inline_desc.Texts = ((D_msg)this.dgvMsg.Rows[row_index].Tag).description; this.AdjustInlineForm(); this.dgvMsg.Enabled = false; this.dgvMsg.SendToBack(); inline_date.BringToFront(); inline_name.BringToFront(); inline_desc.BringToFront(); if (this.dgvMsg.Rows[row_index].Cells[column_index] != null) { if (column_index == 1) { inline_date.Focus(); } else if (column_index == 2) { inline_name.Focus(); } else if (column_index == 3) { inline_desc.Focus(); } } else { inline_date.Focus(); } } }
private void showInlineProblemForm(DataGridViewRow row, int column_index = 1, Problem pattern = null) { this.dgvProblem.Enabled = false; Problem prob = new Problem(); CustomDateTimePicker date = new CustomDateTimePicker(); date.Name = "inline_problem_date"; date.BringToFront(); date.Read_Only = false; date.BorderStyle = BorderStyle.None; date.textBox1.GotFocus += delegate { this.current_focused_control = date; this.toolStripInfo.Text = this.toolTip1.GetToolTip(date); }; toolTip1.SetToolTip(date, "<F6> = Show Calendar"); CustomTextBox name = new CustomTextBox(); name.Name = "inline_problem_name"; name.BringToFront(); name.Read_Only = false; name.BorderStyle = BorderStyle.None; name.textBox1.GotFocus += delegate { this.current_focused_control = name; this.toolStripInfo.Text = this.toolTip1.GetToolTip(name); }; CustomBrowseField probcod = new CustomBrowseField(); probcod.Name = "inline_problem_probcod"; probcod.BringToFront(); probcod._ReadOnly = false; probcod._MaxLength = 2; probcod.BorderStyle = BorderStyle.None; toolTip1.SetToolTip(probcod, "<F6> = Show Problem Code"); probcod._btnBrowse.Click += delegate { IstabList co = new IstabList(this.main_form, probcod._Text, Istab.TABTYP.PROBLEM_CODE); if (co.ShowDialog() == DialogResult.OK) { probcod._Text = co.istab.typcod; } }; CustomTextBoxMaskedWithLabel probdesc = new CustomTextBoxMaskedWithLabel(); probdesc.Name = "inline_problem_probdesc"; probdesc.BringToFront(); probdesc.BorderStyle = BorderStyle.None; probdesc.txtEdit.Enter += delegate { }; probdesc.txtEdit.GotFocus += delegate { if (this.main_form.data_resource.LIST_PROBLEM_CODE.Find(t => t.typcod == probcod._Text) == null) { SendKeys.Send("+{TAB}"); SendKeys.Send("{F6}"); return; } this.current_focused_control = probdesc; this.toolStripInfo.Text = this.toolTip1.GetToolTip(probdesc); }; if (row.Tag is Problem) // edit existing problem { this.FormEditItem(); prob = (Problem)row.Tag; } else // add new problem { this.FormAddItem(); if (pattern != null) prob = (pattern.probcod == "RG" && this.G.loged_in_user_level < GlobalVar.USER_LEVEL_ADMIN ? prob : pattern); } this.dgvProblem.Parent.Controls.Add(date); this.dgvProblem.Parent.Controls.Add(name); this.dgvProblem.Parent.Controls.Add(probcod); this.dgvProblem.Parent.Controls.Add(probdesc); this.dgvProblem.SendToBack(); this.setPositionInlineProblemForm(row); // specify value in each field date.TextsMysql = (row.Tag is Problem ? prob.date : DateTime.Now.ToMysqlDate()); name.Texts = prob.name; probcod._Text = prob.probcod; if (prob.probcod == "RG" && this.main_form.G.loged_in_user_level < GlobalVar.USER_LEVEL_ADMIN) { probcod.Visible = false; probdesc.StaticText = this.GetMachineCode(prob.probdesc); probdesc.EditableText = prob.probdesc.Substring(probdesc.StaticText.Length, prob.probdesc.Length - (probdesc.StaticText.Length)).Trim(); } else { probdesc.StaticText = ""; probdesc.EditableText = prob.probdesc; } if (column_index == 1) { date.Focus(); } else if (column_index == 2) { name.Focus(); } else if (column_index == 3) { if (probcod.Visible) probcod.Focus(); if (!probcod.Visible) probdesc.Focus(); } else if (column_index == 4) { probdesc.Focus(); } }