bool saveToDBAndReload(DBFormatting rule, bool newItem)
        {
            if (isValid(rule))
            {
                if (newItem)
                {
                    DBFormatting.ClearAll();
                    for (int i = 0; i < list.Items.Count; i++)
                    {
                        DBFormatting s = list.Items[i] as DBFormatting;
                        if (s != null)
                        {
                            s[DBFormatting.cIndex] = i;
                            DBFormatting re = new DBFormatting(i);
                            re[DBFormatting.cEnabled] = s[DBFormatting.cEnabled];
                            re[DBFormatting.cReplace] = s[DBFormatting.cReplace];
                            re[DBFormatting.cWith]    = s[DBFormatting.cWith];
                            re.Commit();
                        }
                    }
                    rule[DBFormatting.cIndex] = list.Items.Count;
                }

                rule.Commit();
                LoadFromDB();
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void btnFRDeleteAll_Click(object sender, EventArgs e)
        {
            if (list.Items.Count > 0)
            {
                if (MessageBox.Show("Are you sure you want to delete all Formatting Rules?", "Confirm", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }

                DBFormatting.ClearAll();
                list.Items.Clear();
                enableControls(false);
            }
        }