Ir para conteúdo
Fórum Script Brasil

root1990

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre root1990

root1990's Achievements

0

Reputação

  1. Boa Tarde. estou desenvolvendo uma aplicação simples aqui para empresa porem quero que meu grid atualize sem travar a aplicação. Private Sub carregar() Dim con As New OdbcConnection("") Dim cmd As New OdbcCommand("select numnota 'Numero do Documento', escrit 'Data escrituração' from nota" + txtcodempresa.Text + "" + txtanomov.Text + " where escrit BETWEEN '" + Convert.ToDateTime(txtdatainicial.Text).ToString("yyyy-MM-dd") + "' AND '" + Convert.ToDateTime(txtdatafinal.Text).ToString("yyyy-MM-dd") + "' and itens <= '1' and tpnota = '2' order by numnota desc", con) cmd.Connection.Open() Dim dr As OdbcDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection) While dr.Read() DataGridView1.Rows.Insert(0, dr.GetString(0), dr.GetString(1)) ' Console.WriteLine(dr.GetString(0)) End While ' colorereader() dr.Close() con.Close() t1 = New Thread(AddressOf delegando) t1.Start() End Sub Private Sub delegando() Me.BeginInvoke(New MethodInvoker(AddressOf colorereader)) End Sub Private Sub colorereader() '1: For Each Linha As DataGridViewRow In DataGridView1.Rows If Linha.Index <> DataGridView1.RowCount - 1 Then Try If Linha.Cells(0).Value + 1 <> DataGridView1.Rows(Linha.Index + 1).Cells(0).Value Then Dim valor As String = Linha.Cells(0).Value + 1 Dim zero As String = valor.PadLeft(10, "0") DataGridView1.Rows(Linha.Index + 1).DefaultCellStyle.BackColor = Color.Red ' GoTo 1 End If Catch ex As Exception MsgBox(ex.Message) End Try End If Next End Sub quando eu chamo o coloreader está travando a aplicação, alguém sabe o motivo ?
×
×
  • Criar Novo...