Indenting text from an arraylist...

  • Thread starter Thread starter RAB
  • Start date Start date
R

RAB

I created an arraylist. Some items need to be indented.
....
MyList.Add("Text")
MyList.Add(" Text2")
MyList.Add(" Next text")
.....

I then databind the arraylist with a datalist control. However, the
datalist control does not recognize my spaces and places all text
left-justified. Is there anything I can do to preserve my spaces? The
indentation follow no pattern and are used to create an outline format.

Thanks,
RABMissouri
 
Hello RAB,

I would think you're going to have to add some html formatting in your
display logic. The simplest case would be something along the lines of:

MyList.Add("Text")
MyList.Add(" Text2")
MyList.Add(" Next text")

Or you could probably do something with the <UL> <LI> html elements. Maybe
someone will come up with something more clever for you.
 
I created an arraylist. Some items need to be indented.
...
MyList.Add("Text")
MyList.Add(" Text2")
MyList.Add(" Next text")
....

I then databind the arraylist with a datalist control. However,
the datalist control does not recognize my spaces and places all
text left-justified. Is there anything I can do to preserve my
spaces? The indentation follow no pattern and are used to
create an outline format.

Thanks,
RABMissouri

RAB,

When multiple spaces appear in HTML text, the browser will only
display one space. To display multiple spaces, use the &nbsp;
construct (it stands for "Non Breaking SPace").

So your code could be modified like this:

MyList.Add("Text")
MyList.Add("&nbsp;&nbsp;&nbsp;Text2")
MyList.Add("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next text")


Run this HTML page to see the difference:

<HTML>
<HEAD>
</HEAD>
<BODY>
Line 1
<BR/>
Line 2
<BR/>
Line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3
</BODY>
</HTML>
 

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

Back
Top