[英]vb.net calculation in datagridview
我有一個數據網格視圖,並且在“ 2”列(警報時間)中添加了時間,如下圖所示。
在頂部有一個標簽(label9)。 如果標簽文本顯示為“星期五”,則“警報時間”單元格值應增加10分鍾。 例如,如果標簽顯示星期五,則時間應從16:10:00
更改為16:20:00
。
我的代碼:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Dim myform As New Form2
DataGridView1.Columns(2).DefaultCellStyle.Format = "h:mm:ss"
For i As Integer = 0 To DataGridView1.Rows.Count - 1
If Me.DataGridView1.Rows(i).Cells("AlarmTime").Value = Me.MetroLabel2.Text And Me.DataGridView1.Rows(i).Cells("Frequency").Value = "Weekday" Then
myform.Show()
myform.msgdisply.Text = Me.DataGridView1.Rows(i).Cells("UpdateName").Value
If Me.MetroLabel9.Text = "FRIDAY" Then
Dim iCell1 As String
Dim dt As DateTime
iCell1 = Me.DataGridView1.Rows(i).Cells("AlarmTime").Value
dt = Format(DateTime.Parse(iCell1), "h:mm:ss")
dt.AddMinutes(10)
Me.DataGridView1.Rows(i).Cells("AlarmTime").Value = dt.ToString
End If
next
嘗試這個:
Dim dt as datetime
dt = datetime.parse(iCell1)
dt.addminutes(10)
Me.DataGridView1.Rows(i).Cells("AlarmTime").Value = dt.ToString("HH:mm")
您可以在這里查看addminutes
方法信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.