private void tspSelectPayload_Edit_Click(object sender, EventArgs e) { frmSelect fSelect = (sender as ToolStripButton).Owner.FindForm() as frmSelect; int INDEX = fSelect.lsvSelect.SelectedIndices[0]; frmPAYLOAD fPayloadSelect = new frmPAYLOAD(); tPayLoad_Scenario otPayLoadScenario = tPayLoad_Scenario.byINDEX(INDEX); fPayloadSelect.tspPayload_NamePayload.Text = otPayLoadScenario.tPayLoadData.PayLoad_Name; fPayloadSelect.rtxtContent.Text = otPayLoadScenario.tPayLoadData.PayLoad_Content; if (fPayloadSelect.ShowDialog() == DialogResult.OK) { otPayLoadScenario.tPayLoadData.PayLoad_Name = fPayloadSelect.tspPayload_NamePayload.Text; otPayLoadScenario.tPayLoadData.PayLoad_Content = fPayloadSelect.rtxtContent.Text; otPayLoadScenario.SaveAndFlush(); Update_LV(fSelect.lsvSelect); fSelect.lsvSelect.Items[INDEX].Focused = true; fSelect.lsvSelect.Items[INDEX].Selected = true; } }
private void tspSelectPayload_Add_Click(object sender, EventArgs e) { frmSelect fSelect = (sender as ToolStripButton).Owner.FindForm() as frmSelect; frmPAYLOAD fPayloadSelect = new frmPAYLOAD(); if (fPayloadSelect.ShowDialog() == DialogResult.OK) { tPayLoad_Scenario otPayLoadScenario = new tPayLoad_Scenario(); otPayLoadScenario.tPayLoadData = new tPayLoadData(); otPayLoadScenario.tPayLoadData.PayLoad_Name = fPayloadSelect.tspPayload_NamePayload.Text; otPayLoadScenario.tPayLoadData.PayLoad_Content = fPayloadSelect.rtxtContent.Text; otPayLoadScenario.SaveAndFlush(); Update_LV(fSelect.lsvSelect); fSelect.lsvSelect.Items[fSelect.lsvSelect.Items.Count - 1].Focused = true; fSelect.lsvSelect.Items[fSelect.lsvSelect.Items.Count - 1].Selected = true; } }