/// <summary> /// Insert a new data before a given position /// </summary> /// <param name="list">data list</param> /// <param name="po">printer object</param> /// <returns>added variable</returns> public static bool InsertBefore(ListBox list, PrinterObject po) { if (list.SelectedIndices.Count == 1) { int pos = list.SelectedIndices[0]; Data d = new Data(); FillVars(d.Controls["vars"] as ListBox, po); DialogResult dr = d.ShowDialog(); if (dr == DialogResult.OK) { bool byVar = (d.Controls["rbVariable"] as RadioButton).Checked; if (byVar) { po.InsertUseVariableBefore(pos, d.Controls["vars"].Text); } else { po.InsertDataBefore(pos, d.Controls["txtConst"].Text); } list.Items.Insert(pos, po.Datas.ElementAt(pos)); list.Refresh(); hasModified = true; return(true); } } return(false); }