111,125
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void path_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
private void Cancel_Click(object sender, EventArgs e)
{
textBox1.Text = "";
richTextBox1.Text = "";
}
private void OK_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")//&& int.Parse(textBox1.Text) != 0)
{
//this.timer1.Interval = int.Parse(this.textBox1.Text);
richTextBox1.Text = "";
MessageBox.Show("Please choose a File!");
//this.richTextBox1.Text = "";
}
else
{
FileStream fs = new FileStream(textBox1.Text, FileMode.Open, FileAccess.Read);
StreamReader m_streamReader = new StreamReader(fs);
m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
this.richTextBox1.Text = "";
string strLine = m_streamReader.ReadLine();
while (strLine != null)
{
this.richTextBox1.Text += strLine + "\n";
strLine = m_streamReader.ReadLine();
}
m_streamReader.Close();
string textline;
ArrayList text = new ArrayList();
StreamReader freader = File.OpenText(textBox1.Text);
while ((textline = freader.ReadLine()) != null)
{
if (textline.Length == 0)
continue;
text.Add(textline);
}
}
Form2 frm = new Form2();
frm.Show();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
定义一个结构体
Struct XYZvalue
{
int x;
int y;
int z;
}
Form2中定义这样一个变量
public List<XYZvalue> list=null;
然后
将Form1中X,y,z点对象传过不来
Form2 frm=Form2();
frm.list=//form1中xyz点的集合
frm.Show();