public FormItem()
        {
            InitializeComponent();

            BuildStateList();

            FItem = null;
        }
        public bool TryGetItem(int pId, out DataItem pItem)
        {
            if (FItems.ContainsKey(pId))
            {
                return FItems.TryGetValue(pId, out pItem);
            }

            pItem = null;
            return false;
        }
 public void AddOrSetItem(DataItem pItem)
 {
     if (FItems.ContainsKey(pItem.ID))
     {
         FItems[pItem.ID] = pItem;
     }
     else
     {
         FItems.Add(pItem.ID, pItem);
     }
 }
        public FormItem(ItemFormState pState)
        {
            InitializeComponent();

            FState = pState;

            BuildStateList();

            ApplyCaption();

            FItem = null;
        }
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     // new item
     DataItem tItem = new DataItem();
     // dialog
     FormItem tDlg = new FormItem(ItemFormState.New);
     // set infos
     tDlg.Item = tItem;
     // show modal
     if (tDlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
     {
         // add to list
         tItem = tDlg.Item;
         FItems.AddOrSetItem(tItem);
         // synch entries to database
         if (File.Exists(ApplicationSettings.Singleton.CurrentDBPath))
         {
             FDB.FromItemList(ApplicationSettings.Singleton.CurrentDBPath, FItems);
         }
     }
 }