private void btOK_Click(object sender, EventArgs e)
 {
     Results = new DbParameterListExt();
     for (int i = 0; i < listBox1.Items.Count; i++)
     {
         Results.Add(listBox1.Items[i] as DbCommandParam);
     }
     this.DialogResult = DialogResult.OK;
 }
        private void btNew_Click(object sender, EventArgs e)
        {
            int    n  = 1;
            string nm = "@p1";

            while (true)
            {
                bool bFound = false;
                for (int i = 0; i < listBox1.Items.Count; i++)
                {
                    DbCommandParam p = listBox1.Items[i] as DbCommandParam;
                    if (p != null)
                    {
                        if (string.Compare(nm, p.Name, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            bFound = true;
                            break;
                        }
                    }
                }
                if (bFound)
                {
                    n++;
                    nm = string.Format(CultureInfo.InvariantCulture, "@p{0}", n);
                }
                else
                {
                    break;
                }
            }
            DbCommandParam pNew = new DbCommandParam(new EPField());

            pNew.Name = nm;
            if (Results == null)
            {
                Results = new DbParameterListExt();
            }
            Results.Add(pNew);
            pNew.AfterNameChange += DialogCommandParameters_AfterNameChange;
            n = listBox1.Items.Add(pNew);
            listBox1.SelectedIndex = n;
        }
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         string data = value as string;
         if (!string.IsNullOrEmpty(data))
         {
             string[]           ss = data.Split('|');
             DbParameterListExt ps = new DbParameterListExt();
             for (int i = 0; i < ss.Length; i++)
             {
                 if (!string.IsNullOrEmpty(ss[i]))
                 {
                     string[] ss2 = ss[i].Split(';');
                     if (ss2.Length > 1)
                     {
                         EPField        f = new EPField();
                         DbCommandParam p = new DbCommandParam(f);
                         if (!string.IsNullOrEmpty(ss2[0]))
                         {
                             if (!ss2[0].StartsWith("@", StringComparison.Ordinal))
                             {
                                 f.Name = string.Format(CultureInfo.InvariantCulture, "@{0}", ss2[0]);
                             }
                             else
                             {
                                 f.Name = ss2[0];
                             }
                             if (!string.IsNullOrEmpty(ss2[1]))
                             {
                                 f.OleDbType = (OleDbType)Enum.Parse(typeof(OleDbType), ss2[1]);
                                 if (ss2.Length > 2)
                                 {
                                     int n;
                                     if (int.TryParse(ss2[2], out n))
                                     {
                                         f.DataSize = n;
                                     }
                                     if (ss2.Length > 3)
                                     {
                                         p.Direction = (ParameterDirection)Enum.Parse(typeof(ParameterDirection), ss2[3]);
                                         if (ss2.Length > 4)
                                         {
                                             f.SetValue(ss2[4]);
                                         }
                                     }
                                 }
                                 ps.Add(p);
                             }
                         }
                     }
                 }
             }
             return(ps);
         }
         else
         {
             return(new DbParameterListExt());
         }
     }
     return(base.ConvertFrom(context, culture, value));
 }