lundi 28 août 2017

How do I fire a message box with if else condition and timespan value?

I have this code

*start time is another DateTime.now

*timeSinceStart is an array of timeSpan

*i believe that the for loop is for me to be able to create and store many values for the timespan and update the listview items(see link below for the photo of the form)

*f.ToString() is default 60(its an integer)

*the MH column in the picture is counting upwards, for ex. 1 2 3 4 5 6 etc etc

private void timer2_Tick(object sender, EventArgs e)
    {

        for (int w = 0; w < listView1.Items.Count; w++)
        {
            timeSinceStart[w] = DateTime.Now - startTime[w];
            listView1.Items[w].SubItems[6].Text = (timeSinceStart[w].TotalSeconds.ToString());
            if (f.ToString() == listView1.Items[w].SubItems[6].Text)
            { 
                MessageBox.Show("dedede");
            }
            else
            {
                label3.Text = timeSinceStart[w].TotalSeconds.ToString();
            }
        }

I really cant make the message box pop up and also, the timespan value has decimal values, does it have a connection why the if condition doesn't trigger?

I have tried converting timespan to datetime and use datetime and timespan in the if else condition, it also doesnt seem to work.

here is the picture as i was saying.

Aucun commentaire:

Enregistrer un commentaire