By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

inserting spaces at beginning of listitem string

P: n/a
Have tried a number of things including space(n) in front of the string but
when the DropDownList is shown the spaces have apparently been trimmed.
Is this something that would have to be done in a custom control?
I would like the spaces to be at the front end of the string " xxxxx".
In vs.net I am doing a listitem(string)

Any Help is appreciated.

thanks
barry
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"barry" <fl******@ix.netcom.com> schrieb:
Have tried a number of things including space(n) in front of the string
but
when the DropDownList is shown the spaces have apparently been trimmed.
Is this something that would have to be done in a custom control?
I would like the spaces to be at the front end of the string " xxxxx".
I am not able to reproduce this behavior with .NET 1.1's Windows Forms
combobox control.
In vs.net I am doing a listitem(string)


Could you please post the code you use to populate the combobox?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ColorListBox1.Items.Clear()

Dim liRed As ListItem
Dim liBlue As ListItem

liRed = New ListItem("WebForm1.aspx")
liRed.Attributes.Add("style", "color: blue")
liBlue = New ListItem("WebForm2.aspx")
liBlue.Attributes.Add("style", "color: red")
ColorListBox1.Items.AddRange(New ListItem() {liRed, liBlue})
End Sub

Herfried, the ColorListBox1 is the combobox

If You take the "WebForm1.aspx" and make it " WebForm1.aspx"
this will not show up as being indented in the
combobox which is what I am after.

Thanks

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
"barry" <fl******@ix.netcom.com> schrieb:
Have tried a number of things including space(n) in front of the string
but
when the DropDownList is shown the spaces have apparently been trimmed.
Is this something that would have to be done in a custom control?
I would like the spaces to be at the front end of the string "
xxxxx".
I am not able to reproduce this behavior with .NET 1.1's Windows Forms
combobox control.
In vs.net I am doing a listitem(string)


Could you please post the code you use to populate the combobox?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

P: n/a
Is this a select box on a web page you're trying to populate? If so, try
substituting &nbsp; for the spaces.

Ralf
"barry" <fl******@ix.netcom.com> wrote in message
news:eX**************@tk2msftngp13.phx.gbl...
: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
: System.EventArgs) Handles MyBase.Load
: ColorListBox1.Items.Clear()
:
: Dim liRed As ListItem
: Dim liBlue As ListItem
:
: liRed = New ListItem("WebForm1.aspx")
: liRed.Attributes.Add("style", "color: blue")
: liBlue = New ListItem("WebForm2.aspx")
: liBlue.Attributes.Add("style", "color: red")
: ColorListBox1.Items.AddRange(New ListItem() {liRed, liBlue})
: End Sub
:
: Herfried, the ColorListBox1 is the combobox
:
: If You take the "WebForm1.aspx" and make it " WebForm1.aspx"
: this will not show up as being indented in the
: combobox which is what I am after.
:
: Thanks
:
: "Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
: news:O6**************@tk2msftngp13.phx.gbl...
: > "barry" <fl******@ix.netcom.com> schrieb:
: > > Have tried a number of things including space(n) in front of the
string
: > > but
: > > when the DropDownList is shown the spaces have apparently been
trimmed.
: > > Is this something that would have to be done in a custom control?
: > > I would like the spaces to be at the front end of the string "
: xxxxx".
: >
: > I am not able to reproduce this behavior with .NET 1.1's Windows
Forms
: > combobox control.
: >
: > > In vs.net I am doing a listitem(string)
: >
: > Could you please post the code you use to populate the combobox?
: >
: > --
: > M S Herfried K. Wagner
: > M V P <URL:http://dotnet.mvps.org/>
: > V B <URL:http://classicvb.org/petition/>
: >
:
:
Nov 21 '05 #4

P: n/a
Barry,

I assume you got your help with the &nbsp from Anon

However, there is nothing wrong with posting VBNet ASPNET language problems
to this newsgroup. This was not forever.

Stayed is that Windowsform is the default in this newsgroup.

Although the Dropdownlist is a Webcontrol, can the Windowsform control set
to DropDownList.

Therefore please tell next time that it is for ASPNET or Webform or whatever
to distinct it from Windowsform if that is not direct totally clear.

Thanks in advance

Cor
Nov 21 '05 #5

P: n/a
Hi,

"barry" <fl******@ix.netcom.com> wrote in message
news:eX**************@tk2msftngp13.phx.gbl...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ColorListBox1.Items.Clear()

Dim liRed As ListItem
Dim liBlue As ListItem

liRed = New ListItem("WebForm1.aspx")
liRed.Attributes.Add("style", "color: blue")
liBlue = New ListItem("WebForm2.aspx")
liBlue.Attributes.Add("style", "color: red")
ColorListBox1.Items.AddRange(New ListItem() {liRed, liBlue})
End Sub

Herfried, the ColorListBox1 is the combobox

If You take the "WebForm1.aspx" and make it " WebForm1.aspx"
You should be using &nbsp; but the problem is that the text you put into a
ListItem will be html encoded (at time of render) and so &nbsp; would become
&amp;nbsp; and will not act as a non-breaking-space.

You can use ChrW(160) instead of a space, this will be html encoded into
  which is the same as &nbsp;

Eg. if you want your item to start with 5 spaces then you would do:

liRed = New ListItem( New String(ChrW(160), 5) + "WebForm1.aspx")

HTH,
Greetings

this will not show up as being indented in the
combobox which is what I am after.

Thanks

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
"barry" <fl******@ix.netcom.com> schrieb:
> Have tried a number of things including space(n) in front of the string
> but
> when the DropDownList is shown the spaces have apparently been trimmed.
> Is this something that would have to be done in a custom control?
> I would like the spaces to be at the front end of the string "

xxxxx".

I am not able to reproduce this behavior with .NET 1.1's Windows Forms
combobox control.
> In vs.net I am doing a listitem(string)


Could you please post the code you use to populate the combobox?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Nov 21 '05 #6

P: n/a
Bart, I have spent far to much time on the net looking for what I thought
would be a pretty easy answer but nowhere did I find anything
that even resembled that this was a situation that anyone would want to do.
However, the theme of removing spaces is all over the web.
Thanks for your solution which I have tried and it produces what I was
looking for.

thanks
barry

"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:uu**************@TK2MSFTNGP14.phx.gbl...
Hi,

"barry" <fl******@ix.netcom.com> wrote in message
news:eX**************@tk2msftngp13.phx.gbl...
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ColorListBox1.Items.Clear()

Dim liRed As ListItem
Dim liBlue As ListItem

liRed = New ListItem("WebForm1.aspx")
liRed.Attributes.Add("style", "color: blue")
liBlue = New ListItem("WebForm2.aspx")
liBlue.Attributes.Add("style", "color: red")
ColorListBox1.Items.AddRange(New ListItem() {liRed, liBlue})
End Sub

Herfried, the ColorListBox1 is the combobox

If You take the "WebForm1.aspx" and make it " WebForm1.aspx"
You should be using &nbsp; but the problem is that the text you put into a
ListItem will be html encoded (at time of render) and so &nbsp; would

become &amp;nbsp; and will not act as a non-breaking-space.

You can use ChrW(160) instead of a space, this will be html encoded into
  which is the same as &nbsp;

Eg. if you want your item to start with 5 spaces then you would do:

liRed = New ListItem( New String(ChrW(160), 5) + "WebForm1.aspx")

HTH,
Greetings

this will not show up as being indented in the
combobox which is what I am after.

Thanks

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
"barry" <fl******@ix.netcom.com> schrieb:
> Have tried a number of things including space(n) in front of the string > but
> when the DropDownList is shown the spaces have apparently been trimmed. > Is this something that would have to be done in a custom control?
> I would like the spaces to be at the front end of the string "

xxxxx".

I am not able to reproduce this behavior with .NET 1.1's Windows Forms
combobox control.

> In vs.net I am doing a listitem(string)

Could you please post the code you use to populate the combobox?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>



Nov 21 '05 #7

P: n/a
Thanks I will
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:OM**************@TK2MSFTNGP10.phx.gbl...
Barry,

I assume you got your help with the &nbsp from Anon

However, there is nothing wrong with posting VBNet ASPNET language problems to this newsgroup. This was not forever.

Stayed is that Windowsform is the default in this newsgroup.

Although the Dropdownlist is a Webcontrol, can the Windowsform control set
to DropDownList.

Therefore please tell next time that it is for ASPNET or Webform or whatever to distinct it from Windowsform if that is not direct totally clear.

Thanks in advance

Cor

Nov 21 '05 #8

P: n/a
Thanks I will
"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:OM**************@TK2MSFTNGP10.phx.gbl...
Barry,

I assume you got your help with the &nbsp from Anon

However, there is nothing wrong with posting VBNet ASPNET language problems to this newsgroup. This was not forever.

Stayed is that Windowsform is the default in this newsgroup.

Although the Dropdownlist is a Webcontrol, can the Windowsform control set
to DropDownList.

Therefore please tell next time that it is for ASPNET or Webform or whatever to distinct it from Windowsform if that is not direct totally clear.

Thanks in advance

Cor

Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.