コード例 #1
0
        private void tvFileName_AfterSelect(object sender, TreeViewEventArgs e)
        {
            this.txtItemValue.Text = this.txtEngValue.Text = this.txtCNValue.Text = "";
            if (this.btnSaveChange.Enabled)
            {
                DialogResult result = MessageBox.Show("修改的资源文件没有保存,确定要保存吗?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    this.btnSaveChange_Click(null, null);
                }
                this.btnSaveChange.Enabled = false;
            }

            this.lstvCnFileContent.Items.Clear();
            string sourceFile = this.tvFileName.SelectedNode.Name;

            this.currentFilePath = sourceFile;//临时保存当前操作的文件,方便保存修改
            List <LangItemInfo> fileInfo = op.GetFileLanItemInfo(sourceFile);

            if (fileInfo == null)//未取到对应的文件信息
            {
                return;
            }
            this.currentFileContent = fileInfo;//临时保存,用来修改时的数据保存
            int len = fileInfo.Count;

            if (len > 0)
            {
                ListViewItem[] lviArr = new ListViewItem[len];
                int            index  = 0;
                foreach (var item in fileInfo)
                {
                    ListViewItem lvi = new ListViewItem(new string[] { (index + 1).ToString(), item.ItemText, item.EngText, item.CnText });
                    lviArr[index] = lvi;
                    index++;
                }
                this.lstvCnFileContent.Items.AddRange(lviArr);
            }
        }