Jump to content

Limpar DatagridView


Recommended Posts

Bom dia

Eu preciso de limpar a Datagridview mas já tentei muitas formas e não consigo ..

Alguém me pode ajudar ??

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim abc As String
    abc = Format(DateTimePicker1.Value, "yyyy-MM-dd") & "%"
    Dim abcd As String
    abcd = Format(DateTimePicker2.Value, "yyyy-MM-dd") & "%"
    If DateTimePicker1.Text <> "" And DateTimePicker2.Text <> "" Then
	    Dim dt1 As New DataTable

	    cmd1.Connection = conn
	    cmd1.CommandText = "SELECT Cod_Abate as Abate, SN, Descricao, Data, Motivo, Autorizacao, Cod_Localizacao as Local, Cod_Equipamento as Equipamento from abate where Data between '" & abc & "' and '" & abcd & "'"
	    With DataGridView1
		    .DataSource = dt1
	    End With
    End If
    DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders
    DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill

   End Sub
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.