0

我有一个包含两个标签和一个网格视图的应用程序。在标签中显示 EST & IST 的当前时间。并在网格视图中显示作业名称和时间。我已将所有数据设置为网格视图和标签上的当前时间。现在我想在当前时间与网格时间匹配时播放警报。请建议我怎么做。注意:有很多工作使用相同的时间,因此对于这些工作,警报必须只播放一次。

4

1 回答 1

0

您需要添加计时器来检测当前时间和 DataGridView 值之间的任何匹配。

间隔 = 1 .. 1000(不到一秒)

然后将以下代码添加到计时器中:

    Dim grid_date As DateTime
    Dim Alarm As Boolean = False
    For Each row As DataGridViewRow In **DataGridView1**.Rows
        grid_date = row.Cells(*1*).Value
        If grid_date.ToLongTimeString= DateTime.Now.ToLongTimeStringThen
            Alarm = True
            'do something you want with this row
            **DataGridView1**.Rows.Remove(row)
        End If
    Next
    If Alarm Then My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)

请注意,“ 1 ”是DataGridView1中“时间”列的编号。您可以通过将PlaySystemSound替换为Play ( "c:\alarm.wav" )来播放 .wav 声音文件

于 2013-09-16T12:21:06.817 回答