12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
- {
- public partial class FileNameSelect : Form
- {
- string folderPath = "";
- string PathName = "";
- public string ChangePathName = "";
- public bool yes = false;
- Hashtable table;
- public FileNameSelect(string a_Route, string a_PathName)
- {
- folderPath = a_Route;
- PathName = a_PathName;
- ChangePathName = a_PathName;
- InitializeComponent();
- #region 国际化语言
- OTSCommon.Language lan = new OTSCommon.Language(this);
- table = lan.GetNameTable(this.Name);
- #endregion
- }
- private void FileNameSelect_Load(object sender, EventArgs e)
- {
- listView1.View = View.Details; // 设置视图为Details以显示列标题和子项
- listView1.FullRowSelect = true; // 允许整行选择
- listView1.CheckBoxes = true; // 允许在项旁边显示勾选框
- listView1.Columns.Add(table["file_name"].ToString(), 229); // 添加列标题
- // 获取文件夹中的所有文件信息
- FileInfo[] files = new DirectoryInfo(folderPath).GetFiles("*.xml", SearchOption.AllDirectories);
- // 遍历文件信息数组并打印出文件名
- foreach (FileInfo file in files)
- {
- listView1.Items.Add(file.Name);
- }
- for(int i=0;i<listView1.Items.Count;i++)
- {
- if(ChangePathName== listView1.Items[i].Text)
- {
- listView1.Items[i].Checked = true;
- }
- }
- listView1.ItemCheck += new ItemCheckEventHandler(listView_ItemCheck);
- //label1.Text = PathName;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- for (int i = 0; i < listView1.Items.Count; i++)
- {
- if (listView1.Items[i].Checked)
- ChangePathName = listView1.Items[i].Text;
- }
- yes = true;
- this.Close();
- }
- // 当ListView中的项的检查状态改变时触发的事件处理器
- private void listView_ItemCheck(object sender, ItemCheckEventArgs e)
- {
- for (int i = 0; i < listView1.Items.Count; i++)
- {
- listView1.Items[i].Checked = false;
- }
- listView1.Items[e.Index].Checked = true;
-
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
|