谁能明白为什么我的纬度经度和海拔高度的表格框变回空白?我一直在寻找几个小时,不明白为什么!
namespace DistanceEstimatorFinal
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
dataPoints mydataPoints = new dataPoints();
dataPoint a = mydataPoints.getItem(0);
latTextBox.Text = a.CurLatitude;
longTextbox.Text = a.CurLongtitude;
eleTextBox.Text = a.CurElevation;
}
}
}
以上是我的表格
namespace DistanceEstimatorFinal
{
public class dataPoints
{
List<dataPoint> Points;
public void DataPoints()
{
Points = new List<dataPoint>();
TextReader tr = new StreamReader("c:/users/tom/documents/visual studio 2010/Projects/DistanceCalculator3/DistanceCalculator3/TextFile1.txt");
string input;
while ((input = tr.ReadLine()) != null)
{
string[] bits = input.Split(',');
dataPoint a = new dataPoint(bits[0],bits[1],bits[2]);
Points.Add(a);
}
tr.Close();
}
internal dataPoint getItem(int p)
{
if (p < Points.Count)
{
return Points[p];
}
else
return null;
}
}
}
这是我的点类,它从用逗号分隔的文本文件中绘制点
namespace DistanceEstimatorFinal
{
class dataPoint
{
private string latitude;
private string longtitude;
private string elevation;
public dataPoint(string Latitude, string Longtitude, string Elevation)
{
// TODO: Complete member initialization
this.latitude = Latitude;
this.longtitude = Longtitude;
this.elevation = Elevation;
}
public string CurLongtitude { get { return this.longtitude; } }
public string CurLatitude { get { return this.latitude; } }
public string CurElevation { get { return this.elevation; } }
}
}
上面是保存单个点并将它们发回的类