0

我正在尝试使用此代码刷新我的数据网格时遇到一些缓慢的问题,我正在尝试做的是操作列 ACROSS 变量(selltype_code)。

objConn.Open()

            Dim sqlConn As String = ("SELECT item_code, item_name, item_quantity, selltype_code, item_selldetail FROM qa_items")
            Dim objDataAdapter As New MySqlDataAdapter(sqlConn, objConn)
            Dim ds As New DataSet

            objDataAdapter.Fill(ds, "items")

            'Fill datagridview with FOR CICLE
            For i As Int16 = 0 To ds.Tables("items").Rows.Count - 1
                If ds.Tables("items").Rows(i).Item("selltype_code") = 1 Then
                    With Me.resultitems_seach_item
                        .Item(3, i).Style.ForeColor = ColorTranslator.FromOle(RGB(39, 74, 109)) 'Color para Precio
                        .Item(3, i).Value = ds.Tables("items").Rows(i).Item("item_selldetail") 'Valor para Precio
                        .Item(4, i).Style.ForeColor = Color.DarkGray
                        .Item(4, i).Value = "---"
                        .Item(5, i).Style.ForeColor = Color.DarkGray
                        .Item(5, i).Value = "---"
                        .Item(6, i).Style.ForeColor = Color.DarkGray
                        .Item(6, i).Value = "---"
                    End With
                ElseIf ds.Tables("items").Rows(i).Item("selltype_code") = 2 Then
                    With Me.resultitems_seach_item
                        .Item(3, i).Style.ForeColor = Color.DarkGray
                        .Item(3, i).Value = "---"
                        .Item(4, i).Style.ForeColor = Color.DarkGray
                        .Item(4, i).Value = "---"
                        .Item(5, i).Style.ForeColor = ColorTranslator.FromOle(RGB(39, 74, 109)) 'Color para Precio
                        .Item(5, i).Value = ds.Tables("items").Rows(i).Item("item_selldetail")
                        .Item(6, i).Style.ForeColor = Color.DarkGray
                        .Item(6, i).Value = "---"
                    End With
                ElseIf ds.Tables("items").Rows(i).Item("selltype_code") = 3 Then
                    With Me.resultitems_seach_item
                        .Item(3, i).Style.ForeColor = Color.DarkGray
                        .Item(3, i).Value = "---"
                        .Item(4, i).Style.ForeColor = ColorTranslator.FromOle(RGB(39, 74, 109)) 'Color para Precio
                        .Item(4, i).Value = ds.Tables("items").Rows(i).Item("item_selldetail")
                        .Item(5, i).Style.ForeColor = Color.DarkGray
                        .Item(5, i).Value = "---"
                        .Item(6, i).Style.ForeColor = Color.DarkGray
                        .Item(6, i).Value = "---"
                    End With
                Else
                    With Me.resultitems_seach_item
                        .Item(3, i).Style.ForeColor = Color.DarkGray
                        .Item(3, i).Value = "---"
                        .Item(4, i).Style.ForeColor = Color.DarkGray
                        .Item(4, i).Value = "---"
                        .Item(5, i).Style.ForeColor = Color.DarkGray
                        .Item(5, i).Value = "---"
                        .Item(6, i).Style.ForeColor = ColorTranslator.FromOle(RGB(39, 74, 109)) 'Color para Precio
                        .Item(6, i).Value = ds.Tables("items").Rows(i).Item("item_selldetail")
                    End With
                End If

            Next i

            objConn.Close()
4

1 回答 1

0

确保关闭网格列的任何自动调整大小设置。这大大减慢了获取速度。在进行刷新之前将 Grid AutoresizeMode 设置为 NONE。

于 2012-07-02T20:09:08.043 回答