adding controls to panel

M

Mike P

I am using the following syntax in a loop to add controls to a panel :

this.pnlCharts.Controls.Add(cht);

How can I make it so that there are spaces between each control?
 
A

Alberto Poblacion

Mike P said:
I am using the following syntax in a loop to add controls to a panel :

this.pnlCharts.Controls.Add(cht);

How can I make it so that there are spaces between each control?

I presume this is a Web application (not WinForms) and therefore when you
say "panel" you are referring to an asp:panel control.

In that case, in order to position your controls, you can insert
additional controls such as a Label or a LiteralControl to provide the HTML
markup that will position your own controls. For instance, if you want to
insert a single space between your controls:

this.pnlCharts.Controls.Add(cht1);
this.pnlCharts.Controls.Add(new LiteralControl(" "));
this.pnlCharts.Controls.Add(cht2);

You could also insert a line break by means of new LiteralControl("<br
/>").

Or if you want finer control, you can dynamically create a TABLE and
insert your controls in different TableCells, or create DIVs, add your
controls inside each DIV and apply CSS styles to the DIVs to position them
as needed.
 
G

Gregory A. Beamer

I am using the following syntax in a loop to add controls to a panel :

this.pnlCharts.Controls.Add(cht);

How can I make it so that there are spaces between each control?

Add tables or CSS classes and you can cover the layout/spacing issue. If
you are merely punching into a container, add a bit of padding, via CSS, to
the HTML type the control creates will add some space. If you need precise
layout, you need to either use a table or really think out the CSS. If the
controls added are dynamic in number, tables will be a lot easier, although
the time spent on CSS is generally worth it if you want a great looking UI.
If that is not a concern, then hack away with tables, as they are a bit
easier.


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top