c# - Why can't I reach data within Method? -


i'm trying fill tablelayoutpanel through method goes follows:

private int _rowcount; public void initpaths() {     int c = 1;     int = 1;      while (a < _pathrows.length - 1)     {         var label = new label();         //         // label - format.         //         label.dock = dockstyle.fill;         label.autosize = false;         label.text = _pfadzeilen[a];         label.textalign = system.drawing.contentalignment.middleleft;         label.size = new system.drawing.size(22, 13);         label.backcolor = system.drawing.color.transparent;         tablelayoutp.controls.add(label, 3, c);          //checkboxen einfügen         var cbox = new checkbox();         //         //checkbox format.         cbox.anchor = system.windows.forms.anchorstyles.none;         cbox.autosize = true;         cbox.checkalign = system.drawing.contentalignment.middlecenter;         cbox.name = "checkboxpfad" + a;         cbox.size = new system.drawing.size(15, 14);         cbox.textalign = system.drawing.contentalignment.middlecenter;         cbox.usevisualstylebackcolor = true;         tablelayoutp.controls.add(cbox, 0, c);         a++;         c++;      }      this._rowcount = bibtable.getrowheights().length; // seems holding value within method } 

and delete rows on action, through following method:

public void removerows() {     (int row = _rowcount; row >= 0; row--)     {         bibtable.rowstyles.removeat(row);         bibtable.rowcount--;     } } 

now problem is, if try tablelayoutp outside of method rows initialized, tell me:

object reference not set instance of object.

what can do? there way method inside method (i'm realising how stupid sounds while typing it) or other way deal situation?

you ittering through getrowheights(), returning height of each row. deleting rowstyles collection not directly related first collection. assume getrowheights() returns more rows, rowstyles has.

why not:

bibtable.rowcount = 0; bibtable.rowstyles.clear(); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -