📄 tablefiller.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Data;
namespace PDA_test
{
/// <summary>
/// tableFiller 的摘要说明。
/// </summary>
public class tableFiller : System.Windows.Forms.Form
{
private PDA_test.confirm mF_Form;
private DataRow dr;
private DataSet ds;
private string fname="table";
private System.Windows.Forms.ProgressBar progressBar1;
private string[] sArray;
private DataTable dt1,dt2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
public tableFiller(confirm myform)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
this.mF_Form = myform;
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(16, 40);
this.progressBar1.Size = new System.Drawing.Size(192, 24);
//
// label1
//
this.label1.Location = new System.Drawing.Point(40, 72);
this.label1.Size = new System.Drawing.Size(152, 16);
this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// button1
//
this.button1.Font = new System.Drawing.Font("楷体_GB2312", 15.75F, System.Drawing.FontStyle.Bold);
this.button1.Location = new System.Drawing.Point(56, 88);
this.button1.Size = new System.Drawing.Size(104, 32);
this.button1.Text = "确 定";
this.button1.Click += new System.EventHandler(this.button1_Click);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
//
// tableFiller
//
this.ClientSize = new System.Drawing.Size(224, 128);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.progressBar1);
this.Text = "tableFiller";
this.Load += new System.EventHandler(this.tableFiller_Load);
}
#endregion
private void tableFiller_Load(object sender, System.EventArgs e)
{
StreamReader textID=File.OpenText(fname);
StreamReader textID2=File.OpenText(fname);
dt1 = new DataTable("总表");
dt2 = new DataTable("结果");
string line;
bool tableread=true;
int lineCount=0;
while((line = textID2.ReadLine()) != null)
{
lineCount++;
}
textID2.Close();
try
{
line=textID.ReadLine();
sArray=line.Split('*');
}
catch(IOException ex)
{
MessageBox.Show("table读取失败"+ex);
tableread=false;
}
if(tableread)
{
for(int i=0;i<sArray.Length;i++)
{
dt1.Columns.Add(sArray[i]);
dt2.Columns.Add(sArray[i]);
mF_Form.comboAdd(sArray[i].ToString().Trim());
}
mF_Form.comboSelect(1);
}
//comboBox1.SelectedIndex=1;
progressBar1.Minimum=0;
progressBar1.Maximum=lineCount;
try
{
while((line = textID.ReadLine()) != null)
{
sArray=line.Split('*');
dr = dt1.NewRow();
for(int i=0;i<dr.ItemArray.Length;i++)
{
dr[i]=sArray[i];
}
dt1.Rows.Add(dr);
progressBar1.Value++;
}
textID.Close();
ds = new DataSet();
ds.Tables.Add(dt1);
ds.Tables.Add(dt2);
mF_Form.dsTrans(ds);
}
catch(Exception ex)
{
MessageBox.Show("dataGrid构建失败"+ex);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
//mF_Form.Show();
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -