DataGridView 新有关问题
DataGridView 新问题
请问各位高手,VB 2005里如何在DataGridView最尾处增加一行,值为前面几行的值的和?
------解决方案--------------------
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
DataGridView1.Columns.Add("Columns3", "3header")
'(2,0)为第三列第一行所对应的单元格,剩下的依次类推
Me.DataGridView1()(2, 0).Value = Convert.ToInt16(Me.DataGridView1()(1, 0).Value) + Convert.ToInt16(Me.DataGridView1()(0, 0).Value)
End Sub
------解决方案--------------------
DataGridView1.rows.add(1)
DataGridView1.rows.(DataGridView1.rows.count-1).item(0).value=DataGridView1.rows(0).item(0).value+...+DataGridView1.rows(DataGridView1.rows.count-1).item(0).value
------解决方案--------------------
和我之前的那个问题一抹一样这个是hbxtlhx兄给我的解决方案希望对你有帮助。
Private Sub dataGridView1_CellValidating(ByVal sender As Object, _
ByVal e _
As DataGridViewCellValidatingEventArgs) _
Handles dataGridView1.CellValidating
Me.dataGridView1.Rows(e.RowIndex).ErrorText = " "
Dim newInteger As Integer
' Don 't try to validate the 'new row ' until finished
' editing since there
' is not any point in validating its initial value.
If dataGridView1.Rows(e.RowIndex).IsNewRow Then Return
If Not Integer.TryParse(e.FormattedValue.ToString(), newInteger) _
OrElse newInteger < 0 Then
e.Cancel = True
Me.dataGridView1.Rows(e.RowIndex).ErrorText = "the value must be a non-negative integer "
End If
End Sub
------解决方案--------------------
1樓的是加一列,你的問題可以參考2、3樓的。
------解决方案--------------------
都已经说了
------解决方案--------------------
DataGridView1.rows.add(1)
有时候可能添加不上 程序报错 说DataGridView1在使用中
dim datatable1 as datatable
datatable1 = 你 需要的查询
datatable1.rows.add(1) 'datatable1中添加一行
将你查出的结果计算后赋给该行
DataGridView1.rows.(datatable1.rows.count-1).item(0).value=所有的值
请问各位高手,VB 2005里如何在DataGridView最尾处增加一行,值为前面几行的值的和?
------解决方案--------------------
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
DataGridView1.Columns.Add("Columns3", "3header")
'(2,0)为第三列第一行所对应的单元格,剩下的依次类推
Me.DataGridView1()(2, 0).Value = Convert.ToInt16(Me.DataGridView1()(1, 0).Value) + Convert.ToInt16(Me.DataGridView1()(0, 0).Value)
End Sub
------解决方案--------------------
DataGridView1.rows.add(1)
DataGridView1.rows.(DataGridView1.rows.count-1).item(0).value=DataGridView1.rows(0).item(0).value+...+DataGridView1.rows(DataGridView1.rows.count-1).item(0).value
------解决方案--------------------
和我之前的那个问题一抹一样这个是hbxtlhx兄给我的解决方案希望对你有帮助。
Private Sub dataGridView1_CellValidating(ByVal sender As Object, _
ByVal e _
As DataGridViewCellValidatingEventArgs) _
Handles dataGridView1.CellValidating
Me.dataGridView1.Rows(e.RowIndex).ErrorText = " "
Dim newInteger As Integer
' Don 't try to validate the 'new row ' until finished
' editing since there
' is not any point in validating its initial value.
If dataGridView1.Rows(e.RowIndex).IsNewRow Then Return
If Not Integer.TryParse(e.FormattedValue.ToString(), newInteger) _
OrElse newInteger < 0 Then
e.Cancel = True
Me.dataGridView1.Rows(e.RowIndex).ErrorText = "the value must be a non-negative integer "
End If
End Sub
------解决方案--------------------
1樓的是加一列,你的問題可以參考2、3樓的。
------解决方案--------------------
都已经说了
------解决方案--------------------
DataGridView1.rows.add(1)
有时候可能添加不上 程序报错 说DataGridView1在使用中
dim datatable1 as datatable
datatable1 = 你 需要的查询
datatable1.rows.add(1) 'datatable1中添加一行
将你查出的结果计算后赋给该行
DataGridView1.rows.(datatable1.rows.count-1).item(0).value=所有的值