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

グリッド列の自動サイズ変更設定は必ずオフにしてください。これにより、フェッチが大幅に遅くなります。更新を実行する前に、GridAutoresizeModeをNONEに設定します。

于 2012-07-02T20:09:08.043 に答える