c# - Programmatically Creating and Populating Multiple Listboxes in Grid -
goal: create listbox each parameter on ssrs report.
currently, code works fine if report has 1 parameter. idea populate list of validvalue
objects , add labels listbox. should happen each parameter.
how programmatically create multiple list boxes, populate them using foreach
statements, , add them grid?
here's code:
reportparameterinfocollection parameters; parameters = reportviewer.serverreport.getparameters(); list<string> labels = new list<string>(); list<validvalue> paramlist = new list<validvalue>(); listbox boxbox = new listbox(); foreach (reportparameterinfo param in parameters) { paramlist = param.validvalues.tolist(); labels.clear(); boxbox.items.clear(); foreach (validvalue val in paramlist) { labels.add(val.label + " - " + val.value); } foreach (string lab in labels) { boxbox.items.add(lab); } flygrid.children.add(boxbox); }
edit: see solution below. that's curious, i'm trying around ssrs's poor ui parameters , implement own ui based on in report.
figured out. key create list of listbox objects, , add degree of division grid each time. also, grid.setrow
required avoid overlap. here code ended using:
list<listbox> boxlist = new list<listbox>(); list<string> labels = new list<string>(); list<validvalue> paramlist = new list<validvalue>(); int = 0; foreach (reportparameterinfo param in parameters) { boxlist.add(new listbox()); paramlist = param.validvalues.tolist(); labels.clear(); foreach (validvalue val in paramlist) { labels.add(val.label + " - " + val.value); } foreach (string lab in labels) { boxlist[i].items.add(lab); } flygrid.rowdefinitions.add(new rowdefinition()); flygrid.children.add(boxlist[i]); grid.setrow(boxlist[i], i); boxlist[i].margin = new thickness(20); i++; }
Comments
Post a Comment