where do you call the method getEventTime
and what is notLabel
.
if the method getEventTime
is called and set the notLabel.Text
but after that the text is set again to string.Empty
that there is the problem, so you should probably search or debug every change to notLabel.Text
.
are you sure the it is notLabel
the it is shown in the form? you can check that by registering to the mouseDown
event and see that it is called when you click on the Label
one more thing, add break;
after your line
status = true;
go to the design and press the label, press F4 and search the name
property, i bet it is not notLabel
:
EDIT
i think i fount your problem
correct me if i'm wrong but this lines
if (status)
{
//show Notification Form
Form NotificationForm = new Notification();
NotificationForm.Visible = true;
}
are happening after you change the text... when what you meant is:
public void getEventTime(string filePath, string currDate, string currentDateTimeHM)
{
Form NotificationForm = new Notification();
//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();
NotificationForm.NotText = temp[1].ToString();
status = true;
}
}
if (status)
{
//show Notification Form
NotificationForm.Visible = true;
}
}
and in the notification form do
public string NotText
{
set { notLabel.Text = value; }
}