winforms - Odd DataGridView vertical scrolling behavior -
i have windows forms datagridview. fill , update using code below, pretty straightforward , done on ui thread.
for strange reason size of vertical scrollbar (wich set visible when needed) not reflect amount rows available. if scroll way down, still cannot see last rows. can tell selecting lines below (and bringing them view) using arrow down key.
what possibly reason this. need sort of beginudate or suspendlayout or something? control embedded through interop in mfc application.
andy idea how track down problem? known bug? google doesn't think so, seems.
here code use.
adding or inserting row:
int newrowindex = insertat; if (insertat < 0 || insertat > this.datagridview.rows.count) { newrowindex = this.datagridview.rows.add(); } else { this.datagridview.rows.insert(insertat, 1); }
removing row:
this.datagridview.rows.remove(index);
clearing:
this.datagridview.rows.clear();
updating row:
this.datagrid[0, rowindex].value = somestring; this.datagrid[1, rowindex].value = somebool; this.datagrid[2, rowindex].value = someint;
i had same problem , found when set datagridview's scrollbar property in code opposed designer, worked fine. had along these lines:
foreach(listitem item in list) { //populate grid } datagridview.scrollbars = scrollbars.both;
have no idea why worked :)
Comments
Post a Comment