我想用這個來插入我的datagridview裏面的值:插入數據手動一個DataGridView與添加的列
For Each rows As DataGridViewRow In dgView.Rows
rows.Cells("Ave").Value = Format(Val(dgView.Rows(0).Cells("Qty Issued"))/countMonths).ToString
Next
但有此錯誤:「論證‘表達’不能轉換爲類型‘DataGridViewTextBoxCell’ 「。
這是場景:
我得到了一個datagridview由數據庫中的數據填充。我以編程方式添加了列名「Ave」,然後我想要獲得列的平均值並將其放置到使用循環添加的列「Ave」。我很樂意接受建議。
感謝所有幫助過我的人,我在一天左右的時間裏發現了它。這是新的代碼,我用:
For Each rows As DataGridViewRow In dgView.Rows
ave = rows.Cells("Qty Issued").Value/countMonths
rows.Cells("Ave").Value = Format(ave, "0.00")
Next
@ nempoBu4仍然有同樣的錯誤 – johnprima 2014-12-04 05:10:48