Issue updating rows c# -


i have problem can either update 1 row (and that's it) or 4 @ once.

the issue tbl.rows.addat(tbl.rows.count - 1, tr1) on last 2 lines, comments indicating happens when statement placed there.

there limit of 6, can't figure out why can't update 1 row @ time more once code i've got.

the loops allowing 4 cells per row , no more 4 rows (not including initial row @ start).

can point me in right direction please?

c#:

public void addrows_click1(object sender, eventargs e) {   rmvrows.visible = true;    // rows   (int rowcount = 0; rowcount < 4; rowcount++ )   {     tr1 = new tablerow();     // cells     (int cellcount = 0; cellcount < 4; cellcount++)     {       tc1 = new tablecell();       tb1 = new textbox();       tb1.id = "tbid" + cellcount.tostring();       tc1.controls.add(tb1);       tr1.cells.add(tc1);     }     tbl.rows.addat(tbl.rows.count - 1, tr1);// add 4 more rows   }   tbl.rows.addat(tbl.rows.count - 1, tr1)// adds 1 one no more  } 

this line:

tbl.rows.addat(tbl.rows.count - 1, tr1);// add 4 more rows 

is within for loop running 4 times (from 0 3):

for (int rowcount = 0; rowcount < 4; rowcount++ ) {     tr1 = new tablerow();     /* code omitted */     tbl.rows.addat(tbl.rows.count - 1, tr1);// add 4 more rows } 

the line adds 1 row each time called, getting called 4 times. therefore, table has 4 additional rows after for loop's execution.

as second line:

tbl.rows.addat(tbl.rows.count - 1, tr1)// adds 1 one no more  

this outside of loop, so, other normal code, executes once. since executes once, adds 1 row.

additionally, since tr1 not changed after for loop, final row added last line going duplicate of whatever last row created loop was.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -