C
CM16
Guest
Hi. Firstly thank's for your time.
I would like to know, how i can do to to paint the cells of a datagridview faster. I have a datagridview that is filled recursively.
The code:
For Each reg As DataRow In RegTable
DgReg.Rows.Add(ImageList1.Images(reg.Item("id")), reg.Item(“status”), reg.Item(“#reg”), reg.Item(“date”), reg.Item(“#Alternative”), reg.Item(“CodCustomer”), reg.Item(“Customer”), False, "", 0)
PaintRow(DgReg.Rows(DgReg.RowCount - 1))
Next
Sub PaintRow(row As DataGridViewRowr)
If row.Cells("Status").Value = 1 Then
For Each celda As DataGridViewCell In row.Cells
celda.Style.BackColor = GetColor (4)
celda.Style.ForeColor = Color.Black
Next
End If
If row.Cells("Status ").Value = 2 Then
For Each celda As DataGridViewCell In row.Cells
celda.Style.BackColor = GetColor(5)
celda.Style.ForeColor = Color.Black
Next
End If
End Sub
That work's but the datagridview have more than 5000 rows, and i am triying make it better.
Further, i need to call PaintRow() everytime that the DatagridviewColumn order changes.
I hope you can help me.
Continue reading...
I would like to know, how i can do to to paint the cells of a datagridview faster. I have a datagridview that is filled recursively.
The code:
For Each reg As DataRow In RegTable
DgReg.Rows.Add(ImageList1.Images(reg.Item("id")), reg.Item(“status”), reg.Item(“#reg”), reg.Item(“date”), reg.Item(“#Alternative”), reg.Item(“CodCustomer”), reg.Item(“Customer”), False, "", 0)
PaintRow(DgReg.Rows(DgReg.RowCount - 1))
Next
Sub PaintRow(row As DataGridViewRowr)
If row.Cells("Status").Value = 1 Then
For Each celda As DataGridViewCell In row.Cells
celda.Style.BackColor = GetColor (4)
celda.Style.ForeColor = Color.Black
Next
End If
If row.Cells("Status ").Value = 2 Then
For Each celda As DataGridViewCell In row.Cells
celda.Style.BackColor = GetColor(5)
celda.Style.ForeColor = Color.Black
Next
End If
End Sub
That work's but the datagridview have more than 5000 rows, and i am triying make it better.
Further, i need to call PaintRow() everytime that the DatagridviewColumn order changes.
I hope you can help me.
Continue reading...