How to delete a row in a grid in C# windows phone 8.1 -
i have started developing windows phone application i'm creating row in grid dynamically. upon conditions need delete row , content in row.
here sample code.
result = e.parameter string; string[] acst = result.split('|'); int j = 0; root2.rowdefinitions.add(new rowdefinition() { height = new gridlength(10) }); (int = 6; < acst.length - 1; i++) { textblock mytextblock = new textblock(); mytextblock.name = "txtdetails" + root2.children.count + 1; mytextblock.text = acst[i + 1]; if (mytextblock.text != "") { if (mytextblock.text.trim() != "0.00") // if result 0.00 have delete content in row. { if (j == 0) { mytextblock.fontsize = 14; mytextblock.istextscalefactorenabled = false; mytextblock.horizontalalignment = horizontalalignment.stretch; mytextblock.verticalalignment = verticalalignment.center; grid.setcolumn(mytextblock, 1); grid.setrow(mytextblock, (i) / 6); j++; } else if (j == 1) { mytextblock.fontsize = 14; mytextblock.istextscalefactorenabled = false; mytextblock.visibility = visibility.collapsed; mytextblock.horizontalalignment = horizontalalignment.center; mytextblock.verticalalignment = verticalalignment.center; grid.setcolumn(mytextblock, 2); grid.setrow(mytextblock, (i) / 6); j++; } else if (j == 2) { mytextblock.fontsize = 14; mytextblock.istextscalefactorenabled = false; mytextblock.textwrapping = textwrapping.wrap; mytextblock.horizontalalignment = horizontalalignment.left; mytextblock.verticalalignment = verticalalignment.center; grid.setcolumn(mytextblock, 3); grid.setrow(mytextblock, (i) / 6); j=0; root2.rowdefinitions.add(new rowdefinition() { height = new gridlength(60) }); } } root2.children.add(mytextblock); } else { root2.rowdefinitions.removeat((i / 6)); // here i'm getting arugument exception } }
for example if mytextblock.text = 0.00 in third column (j=2 in case). need remove content in column 1 , 2 or delete thst particular row.
i've tried "root2.rowdefinitions.removeat" there getting arugument exception. i'm missing?
any highly appreciated.
initially grid has 1 row creating index 0. when executing root2.rowdefinitions.removeat((i / 6));
getting root2.rowdefinitions.removeat(1);
should use root2.rowdefinitions.removeat((i / 6)-1);
solve exception
to answer second question code confusing. listing some
1: why starting loop 6 2: why dividing i/6 3: getting result
Comments
Post a Comment