如何存储和检索winform c#按钮添加的列表元素?

时间:2017-01-19 00:14:52

标签: c# xml database winforms list

如何存储和检索winform c#按钮添加的列表元素?我正在尝试添加和删除我的块网站列表,但一旦我退出应用程序并重新启动它重置元素,这里是下面的片段

 public partial class Form1 : Form

{

     private List<string> BlockList = new List<string>() { "http://www.google.com", "http://www.google.co.uk", "http://www.bing.com" };


private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {



            // BlockList.Add("http://www.google.com");
             //BlockList.Add("http://www.google.co.uk");
            // BlockList.Add("http://www.bing.com"); 

            string[] BlockArray = BlockList.ToArray();  



            for (int i = 0; i < BlockArray.Length; i++)

            {
                if (e.Url.Equals(BlockList[i]))

                {
                    e.Cancel = true;
                    MessageBox.Show("Booyaa Says No!", "NO NO NO", MessageBoxButtons.OK, MessageBoxIcon.Hand); // Block List Error Message
                }



    private void button6_Click_1(object sender, EventArgs e)
    {
       BlockList.Add(textBox2.Text);
    }
    private void button7_Click_1(object sender, EventArgs e)
            {
                BlockList.Remove(textBox3.Text);
            }

0 个答案:

没有答案