Exemple #1
0
 private void ExcelSheetBindComBoBoxItems(AisinoCMB bobox, string path)
 {
     try
     {
         bobox.Items.Clear();
         if (!File.Exists(path))
         {
             MessageBoxHelper.Show(path + "文件不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             DataTable excelTableNames = ExcelRead.GetExcelTableNames(path);
             bobox.Text = excelTableNames.Rows[0][2].ToString().Trim(new char[] { '$' });
             for (int i = 0; i < excelTableNames.Rows.Count; i++)
             {
                 string str  = excelTableNames.Rows[i][2].ToString().Trim();
                 int    num2 = 0;
                 if (str[str.Length - 1] != '$')
                 {
                     num2 = 1;
                 }
                 for (int j = 0; j < bobox.Items.Count; j++)
                 {
                     if (bobox.Items[j].ToString() == str)
                     {
                         num2 = 1;
                     }
                 }
                 if (num2 == 0)
                 {
                     bobox.Items.Add(str.Trim(new char[] { '$' }));
                 }
             }
         }
     }
     catch (Exception exception)
     {
         MessageBoxHelper.Show(exception.ToString(), "异常");
     }
 }