注意ComboBox.SelectedValue==null时的空指针异常
3.str = ComboBox1.SelectedItem
可以获取选中的值
------------------------------------------------------------
4. For Each DataGridViewRow As DataGridViewRow In DataGridView1.SelectedRows
DataGridView1.Rows.RemoveAt(DataGridViewRow.Index)
Next
删除选中行
--------------------------------------
5.RSS = MessageBox.Show(Me,"确定要删除选中行数据码?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning)
Select Case RSS
Case DialogResult.Yes
MsgBox(Me.DataGridView1.SelectedRows.Count)
End Select
End Sub
---------------------------------------------------------
6. For i = DataGridView1.Rows.Count - 1 To 0 Step -1
Dim cells As DataGridViewCheckBoxCell
MsgBox(i)
cells = DataGridView1.Rows(i).Cells("selectmy")
If Convert.ToBoolean(cells.EditedFormattedValue) Then
DataGridView1.Rows.RemoveAt(i) '这里只是逻辑删除,可以将要删除的数据保存到一个临时表里,然后当用户确实想删除的时候再更新数据库
dt.Columns.Add()dt.Rows.Add() End If
Next
删除选中的列
--------------------------------------------------------------
7. If Not IsDate(TextBox1.Text) Then
MsgBox("您的输入的日期有误,日期为8位纯数字")
Exit Sub
End If
判断用户输入的日期是否有误
注意:这里日期的格式要是1990-02-03才行要不然,isDate()会报错
----------------------------------------------- 8.