当图片框为空或填充时启用和禁用命令按钮

Enable and disable command button when picture box is empty or filled

我正在做数据添加和更新的项目。以下代码仅在所有文本字段都已填写且从文件上传图像时才启用命令按钮,但即使图片框中的图像为空,命令按钮也会启用。请帮助我在图像填充和清空时启用和禁用命令按钮。

Private Sub txtfields_TextChanged(sender As Object, e As EventArgs) Handles txtpassword.TextChanged
    If Not String.IsNullOrWhiteSpace(txtid.Text) AndAlso Not String.IsNullOrWhiteSpace(txtname.Text) AndAlso Not String.IsNullOrWhiteSpace(txtusername.Text) AndAlso Not String.IsNullOrWhiteSpace(txtpassword.Text) AndAlso picuser.Image Is Nothing Then
        btnadd.Enabled = True
    End If
End Sub

你写了 AndAlso picuser.Image Is Nothing Then 这意味着 "if the image is nothing"

我建议您将该部分更改为:

AndAlso picuser.Image is nothing = false then

希望对您有所帮助! :)