Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            //NameValueCollection nvc = new NameValueCollection();
            Dictionary <string, string> nvc = new Dictionary <string, string>();

            for (int i = 0; i < this.listView1.Items.Count; i++)
            {
                if (this.listView1.Items[i].Checked)
                {
                    string insa = this.listView1.Items[i].SubItems[1].Text;
                    string ins  = this.listView1.Items[i].SubItems[4].Text;
                    if (!nvc.ContainsKey(insa))
                    {
                        nvc.Add(insa, ins);
                    }
                }
            }
            try
            {
                ObjectToBin.Serialize(nvc, System.Environment.CurrentDirectory + "\\jincheng.Bin");
                MessageBox.Show("保存成功!");
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        void OnLoadCheck()
        {
            Dictionary <string, string> nvc = null;

            nvc = ObjectToBin.DeSerialize <Dictionary <string, string> >(System.Environment.CurrentDirectory + "\\jincheng.Bin");
            for (int i = 0; i < this.listView1.Items.Count; i++)
            {
                if (nvc != null && nvc.Keys.Count > 0)
                {
                    foreach (var item in nvc.Keys)
                    {
                        string insa = this.listView1.Items[i].SubItems[1].Text;
                        string ins  = this.listView1.Items[i].SubItems[4].Text;
                        if (item.ToString() == insa && nvc[item.ToString()].ToString() == ins)
                        {
                            this.listView1.Items[i].Checked  = true;
                            this.listView1.Items[i].Selected = true;
                        }
                    }
                }
            }
        }