private void frmCustomizeColumnsIN_Load(object sender, EventArgs e)
 {
     if (mode == "IN")
     {
         FileInfo fi = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//INHW.txt");
         if (fi.Exists)
         {
             StreamReader sr = new StreamReader(fi.FullName);
             clms = new List <clm>();
             while (!sr.EndOfStream)
             {
                 string x = sr.ReadLine().Trim();
                 clm    c = new clm();
                 c.clmname = x.Split('^')[0];
                 int n = 100;
                 int.TryParse(x.Split('^')[1], out n);
                 c.clmwidth = n;
                 if (x.Split('^').Length >= 3)
                 {
                     clmprop cp = clmprops.FirstOrDefault <clmprop>(m => m.clmValue.Trim().ToLower() == x.Split('^')[0].Trim().ToLower());
                     if (cp == null)
                     {
                         continue;
                     }
                     int k = checkedListBox1.Items.IndexOf(cp.clmName);
                     if (k < 0)
                     {
                         continue;
                     }
                     bool b = true;
                     bool.TryParse(x.Split('^')[2], out b);
                     c.clmvisible = b;
                     checkedListBox1.SetItemChecked(k, b);
                     if (x.Split('^').Length == 4)
                     {
                         c.clmtext = x.Split('^')[3];
                     }
                 }
                 clms.Add(c);
             }
             sr.Close();
             sr.Dispose();
             sr = null;
         }
         else
         {
         }
     }
     else if (mode == "OUT")
     {
         FileInfo fi = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//OUTHW.txt");
         if (fi.Exists)
         {
             StreamReader sr = new StreamReader(fi.FullName);
             clms = new List <clm>();
             while (!sr.EndOfStream)
             {
                 string x = sr.ReadLine().Trim();
                 clm    c = new clm();
                 c.clmname = x.Split('^')[0];
                 int n = 100;
                 int.TryParse(x.Split('^')[1], out n);
                 c.clmwidth = n;
                 if (x.Split('^').Length >= 3)
                 {
                     clmprop cp = clmprops.FirstOrDefault <clmprop>(m => m.clmValue.Trim().ToLower() == x.Split('^')[0].Trim().ToLower());
                     if (cp == null)
                     {
                         continue;
                     }
                     int k = checkedListBox1.Items.IndexOf(cp.clmName);
                     if (k < 0)
                     {
                         continue;
                     }
                     bool b = true;
                     bool.TryParse(x.Split('^')[2], out b);
                     c.clmvisible = b;
                     checkedListBox1.SetItemChecked(k, b);
                     if (x.Split('^').Length == 4)
                     {
                         c.clmtext = x.Split('^')[3];
                     }
                 }
                 clms.Add(c);
             }
             sr.Close();
             sr.Dispose();
             sr = null;
         }
         else
         {
         }
     }
 }
        private void frmCustomizeColumnsIN_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (mode == "IN")
                {
                    FileInfo fi = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//INHW.txt");
                    //if (!fi.Exists)
                    //{
                    //    fi.Create();
                    //}
                    StreamWriter sw = new StreamWriter(fi.FullName, false);
                    sw.Flush();

                    for (int i = 0; i < checkedListBox1.Items.Count; i++)
                    {
                        clmprop cp = clmprops.FirstOrDefault <clmprop>(m => m.clmName.Trim().ToLower() == checkedListBox1.Items[i].ToString().Trim().ToLower());
                        if (cp != null)
                        {
                            if (clms == null)
                            {
                                sw.WriteLine(cp.clmValue + "^100^" + checkedListBox1.GetItemChecked(i).ToString());
                                continue;
                            }
                            clm c = clms.FirstOrDefault <clm>(m => m.clmname.ToLower().Trim() == cp.clmValue.ToLower().Trim());
                            if (c != null)
                            {
                                sw.WriteLine(c.clmname + "^" + c.clmwidth + "^" + checkedListBox1.GetItemChecked(i).ToString() + (string.IsNullOrWhiteSpace(c.clmtext)?"":"^" + c.clmtext));
                            }
                            else
                            {
                                sw.WriteLine(cp.clmValue + "^100^" + checkedListBox1.GetItemChecked(i).ToString());
                            }
                        }
                    }

                    sw.WriteLine("Column1^38^True");
                    sw.WriteLine("Colmun7^59^True");
                    sw.WriteLine("Colmun8^39^True");
                    sw.WriteLine("Colmun9^59^True");
                    sw.WriteLine("Colmun10^69^True");
                    sw.WriteLine("Colmun11^47^True");
                    sw.Close();
                    sw.Dispose();
                    sw = null;
                }
                else if (mode == "OUT")
                {
                    FileInfo fi = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//OUTHW.txt");
                    //if (!fi.Exists)
                    //{
                    //    fi.Create();
                    //}
                    StreamWriter sw = new StreamWriter(fi.FullName, false);
                    sw.Flush();

                    for (int i = 0; i < checkedListBox1.Items.Count; i++)
                    {
                        clmprop cp = clmprops.FirstOrDefault <clmprop>(m => m.clmName.Trim().ToLower() == checkedListBox1.Items[i].ToString().Trim().ToLower());
                        if (cp != null)
                        {
                            if (clms == null)
                            {
                                sw.WriteLine(cp.clmValue + "^100^" + checkedListBox1.GetItemChecked(i).ToString());
                                continue;
                            }
                            clm c = clms.FirstOrDefault <clm>(m => m.clmname.ToLower().Trim() == cp.clmValue.ToLower().Trim());
                            if (c != null)
                            {
                                sw.WriteLine(c.clmname + "^" + c.clmwidth + "^" + checkedListBox1.GetItemChecked(i).ToString() + (string.IsNullOrWhiteSpace(c.clmtext) ? "" : "^" + c.clmtext));
                            }
                            else
                            {
                                sw.WriteLine(cp.clmValue + "^100^" + checkedListBox1.GetItemChecked(i).ToString());
                            }
                        }
                    }

                    sw.WriteLine("Column1^38^True");
                    sw.WriteLine("Colmun7^59^True");
                    sw.WriteLine("Colmun8^39^True");
                    sw.WriteLine("Colmun9^59^True");
                    sw.WriteLine("Colmun10^69^True");
                    sw.WriteLine("Colmun11^47^True");
                    sw.Close();
                    sw.Dispose();
                    sw = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }