我有2个datagridviews(dgv1& dgv2)填充了具有相同列的行。
我希望从dgv2循环到dgv1的行,如果一个单元格大于dgv2中的行,我想为单元格的背景着色以标记它已超出。
我确实通过使用foreach来实现它,但是处理过程需要很长时间。我可以用任何方式比较可能更快的单元格。因为atm一次进入一次单元格滚动所有100个dgv1行然后移动到下一个单元格需要很长时间,我确信我效率低下。
library(data.table)
## convert both data.frames to data.tables by reference
setDT(df1)
setDT(df2)
# join by id and date within start & end limits
# "x." is used so we can refer to the column in df1 explicitly
df2[df1, .(id, date = x.date, start, end),
on = .(id, date >= start, date <= end)]
#> id date start end
#> 1: 1 2012-07-05 2012-07-05 2012-07-15
#> 2: 1 2012-07-06 2012-07-05 2012-07-15
#> 3: 1 2012-07-07 2012-07-05 2012-07-15
#> 4: 1 2012-07-08 2012-07-05 2012-07-15
#> 5: 1 2012-07-09 2012-07-05 2012-07-15
#> 6: 1 2012-07-10 2012-07-05 2012-07-15
#> 7: 1 2012-07-11 2012-07-05 2012-07-15
#> 8: 1 2012-07-12 2012-07-05 2012-07-15
#> 9: 1 2012-07-13 2012-07-05 2012-07-15
#> 10: 1 2012-07-14 2012-07-05 2012-07-15
#> 11: 1 2012-07-15 2012-07-05 2012-07-15