[英]how to Add column cell value in datagridview to previouse column cell value
this my code iwant to add column cellvalue in datagridview to previouse number of cells user insert the summ variable always equal zero 这是我的代码想要将datagridview中的列cellvalue添加到先前的单元格数量中,用户插入summ变量始终等于零
any help 任何帮助
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
year = TextBox1.Text
month = TextBox2.Text
noofmonths = TextBox3.Text
Dim summ As String
summ = 0
Dim rowindex As Integer
For Each row As DataGridViewRow In DataGridView1.Rows
If row.Cells.Item(1).Value = TextBox1.Text Then
If row.Cells.Item(2).Value = TextBox2.Text Then
rowindex = row.Index
For i As Integer = rowindex To noofmonths And i <> 0
summ = row.Cells.Item(3).Value + summ
rowindex = row.Index - 1
i = i - 1
Next
summ = summ / noofmonths.ToString
rowindex = rowindex + noofmonths
Dim actie As String = row.Cells(3).Value.ToString()
row.Cells(4).Value = summ
MsgBox(summ)
Else
MsgBox("Item not found")
End If
End If
Next
Try using 尝试使用
If row.Cells.Item(1).Value = TextBox1.Text and row.Cells.Item(2).Value = TextBox2.Text Then
instead of 代替
If row.Cells.Item(1).Value = TextBox1.Text Then
If row.Cells.Item(2).Value = TextBox2.Text Then
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.