vb.net - Datagridview Row Post Paint infinite loop issue -
i programming in vb.net inside windows forms sql end. issue using 2 separate sql queries try , color multiple datagridview rows yellow, red, or green. problem each row, check row see if should yellow, , check same row see if should green. set rows red begin with. think problem if row set red, when change yellow, restarts the row post paint event.
private sub datagridview1_rowpostpaint(sender object, e datagridviewrowpostpainteventargs) handles datagridview1.rowpostpaint datagridview1.defaultcellstyle.backcolor = color.red using conn1 new sqlconnection(connstring) conn1.open() using comm1 new sqlcommand("select * table1 orderno = @order , left(item, 10) = @part , [cut?] = 1", conn1) comm1.parameters .addwithvalue("@order", datagridview1.rows(e.rowindex).cells("orderno").value) .addwithvalue("@part", datagridview1.rows(e.rowindex).cells("part").value) end dim dt new datatable dim sql new sqldataadapter(comm1) sql.fill(dt) if dt.rows.count >= 1 datagridview1.rows(e.rowindex).defaultcellstyle.backcolor = color.yellow end if end using conn1.close() end using using conn1 new sqlconnection(connstring) conn1.open() using comm1 new sqlcommand("select * table1 orderno = @order , left(itemnum, 10) = @part , [completed?] = 1", conn1) comm1.parameters .addwithvalue("@order", datagridview1(e.rowindex).cells("order").value) .addwithvalue("@part", datagridview1.rows(e.rowindex).cells("part").value) end dim dt new datatable dim sql new sqldataadapter(comm1) sql.fill(dt) if dt.rows.count >= 1 datagridview1.rows(e.rowindex).defaultcellstyle.backcolor = color.green end if end using conn1.close() end using end sub
the datagridview load , color in rows program doing because cells blink if program doing rows. form freezes up, not in crashed, in form unresponsive because busy running row post paint code. need find way code run once on each line , stop.
Comments
Post a Comment