试着做下一步 - 我想检查一些信息是否已经存在,如果是csv文件,如果是的话 - 打开带标签的表格,并把文件中的信息放到 代码是下一个:为什么element.Text =不工作
public void getEventTime(string filePath, string currDate, string currentDateTimeHM)
{
//reading the *.csv file and convert to the array of data
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
//create array for getting any vlaue from string
string[] arrOfData = sr.ReadToEnd().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
sr.Close();
List<string> lines = new List<string>();
bool status=false;//variable for showing form if event exist
foreach (var l in arrOfData)
{
if (l.Contains(currDate) && l.Contains(currentDateTimeHM))
{
string[] temp = l.Split(',').Take(5).ToArray();
notLabel.Text = temp[1].ToString();
status = true;
}
}
if (status)
{
//show Notification Form
Form NotificationForm = new Notification();
NotificationForm.Visible = true;
}
}
一切完美的作品 - 如果信息存在 - 新形式打开,但notLabel.Text = temp[0].ToString();
这部分有什么回报。在调试过程中,我得到了下一个
意味着代码是正确的,但对我来说,奇怪的原因导致程序 - 没有这个文本。 我犯了什么错误?
下面表格标签
检查
几排从文件NotificationDesigner.Form.cs
this.notLabel.AutoSize = true;
this.notLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.notLabel.Location = new System.Drawing.Point(12, 22);
this.notLabel.Name = "notLabel";
this.notLabel.Size = new System.Drawing.Size(34, 13);
this.notLabel.TabIndex = 0;
this.notLabel.Text = "label";
您是在设计器还是编程添加标签? – keyboardP
我手动添加标签到disigner窗体,名称 - notLabel – gbk