对于你的问题(确保datagridview1.AutoGenerateColumns = True
):
Private Sub DataGridView1_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) _
Handles datagridview1.CellValidating
e.Cancel = Not IsNumeric(DataGridView1.Item(e.ColumnIndex, e.RowIndex))
End Sub
Private Sub DataGridView1_DataBindingComplete(sender As Object, e As DataGridViewBindingCompleteEventArgs) _
Handles DataGridView1.DataBindingComplete
For Each col As DataGridViewColumn In DataGridView1.Columns
Select Case col.DataPropertyName
Case "Col1" ' from Table or Linq
col.HeaderText = "My Column 1"
Case "Col2" ' from Table or Linq
col.HeaderText = "My Column 2"
' '' etc for each column
End Select
Next
End Sub
你必须调用threeContext.SaveChanges转发更改源数据库。 –
@AlinI正确的budy我正在调用一个新的dbcontext不能让beleive把一个合适的anser放在他们的感谢之中你不知道如何将gridview条目文本框修改为数字 – rogue39nin
cellvalidating event put:** e.Cancel = Not IsNumeric(e .FormattedValue)** –