It also helps us visualize, how placing a certain field would reflect in the actual report by simply clicking on the Preview button and taking a look at it.
Imagine the same convenience for a report that was not created using a designer, or if just a quick view was needed to see all the fields in the report and check the view by changing visibility at the same time.
Call it a tool or a small application, the attached sample is an effort to read all the fields in an existing report, toggle their visibility, and immediately see how the report looks with/without that field.
It is just an initial version, there can be many applications for it as an extensibility tool in certain apps, or as a simpler designer as well, though not in the complete sense. :)
For the matter of explaining the approach, there are only two
1) Read all the fields present in the report, and load them up in a list box for easy accessibility, using the following code,
foreach (Field f in c1Report1.Fields)
2) On any appropriate event, set the following code to toggle the visibility, of the selected field, and immediately, since it is required as per the attached sample, to update the Report document as well, and to view the field again, set the visibility "True", on another event.
c1Report1.Fields[listBox1.SelectedItem.ToString()].Visible = false;
printPreviewControl1.Document = c1Report1.Document;
In the attached sample, I have used two buttons to toggle the selected field's visibility, on and off, just so it's simple, and re rendered the report document, to update the fields status, in the same code segment.