For Each c As Control In Me.Controls If TypeOf c Is TextBox Then c.Text = "" Next 应该这样写
上面判断类型错误了 改一下 for each c as control in me.controls if TypeOf c is textbox then c.Text="" end if next 清空DataGridView For i As Integer = 0 To dg.Rows.Count - 1 For j As Integer = 0 To dg.Columns.Count - 1 dg(j, i) = Nothing Next Next
for each c as control in me.controls
if c.gettype()==typeof(textbox) then
c.Text=""
end if
next
那清空datagridview的内容呢 我这个datagridview是绑定了数据库的数据 加载程序的时候就把这些数据读出来了 这些数据可以修改的 我清空的意思是 文本框清空 datagridview的数据重新从数据库加载一下
If TypeOf c Is TextBox Then c.Text = ""
Next 应该这样写
改一下
for each c as control in me.controls
if TypeOf c is textbox then
c.Text=""
end if
next
清空DataGridView
For i As Integer = 0 To dg.Rows.Count - 1
For j As Integer = 0 To dg.Columns.Count - 1
dg(j, i) = Nothing
Next
Next