Groups | Blog | Home
all groups > asp.net webcontrols > march 2004 >

asp.net webcontrols : Problem formatting text in a ListBox



Mike
3/30/2004 5:47:06 PM

Hi,

I am trying to format some text that I retrieve from a DB. I load the =
converted (to string) values in an array and then use the following =
statement:

lstChartAccounts.Items.Add(String.Format("{0:15} {1:50} {2:10} =
{3:10}", value))

I would like my ListBox (WebControl) to show the data "tabbed," but I =
cannot make it work. Any idea on what is wrong here?

Thanks
hrothenb
6/10/2004 8:14:02 AM
I have been able to get a tab like effect using an encoded string:

Dim EncodedString As String = " "
Dim writer As New System.IO.StringWriter
Server.HtmlDecode(EncodedString, writer)
Dim DecodedString As String = writer.ToString()

strNewItem = "Data to Add" & DecodedString

lstTheListBox.Items.Add(New ListItem(strNewItem))

[quoted text, click to view]
hrothenb
6/10/2004 12:59:01 PM
There should be the following value in the EncodedString



It didn't show in my first reply.

Using the encoded string, I have been able to get close to a multicolumn or tabbed listbox.

It works about the same with

If anyone has any advice to improve the results, please comment further.


[quoted text, click to view]
hrothenb NO[at]SPAM bcpl.net
6/14/2004 6:37:25 AM
This function is useful for making the padded string to add to the end
of the listbox item.

Private Function PadHTML(ByVal numberOfSpaces As Int32) As String

Dim Spaces As String

For items As Int32 = 1 To numberOfSpaces
Spaces &= " "
Next

Return Server.HtmlDecode(Spaces)

End Function

[quoted text, click to view]
AddThis Social Bookmark Button