473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

inserting spaces at beginning of listitem string

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
8 3261
"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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael Albanese | last post by:
I am building an application to report on-the-job injuries and incidents. There are a lot of Date fields, some of which are optional and can be left blank by the user. I have allowed Nulls on...
0
by: Chumley the Walrus | last post by:
I'm trying to add a drop down list to my data insertion script, using the sqlparamter object . The form coding on the web page: <asp:dropdownlist id="frmstate" runat="server"> <asp:ListItem...
6
by: Manan | last post by:
hello All, I have a simple question..I'm creating a tempString that contains my values then i'm adding to a ListItemCollection (). In my tempString i'm adding a spaces between each values it...
11
by: Lucas Campos | last post by:
Hello, I'm using a dropdownlist web control. This dropdownlist has a problem with some descriptions I'd like to show. The description is "XXX JJJ", but it shows in the browser "XXX JJJ" (it...
2
by: Alan Silver | last post by:
Hello, VWD Express seems obsessed with inserting loads of spaces at the start of each line whenever you drag controls into the source view. I guess this is MS' idea of making the source code...
5
by: hfk0 | last post by:
Hi, I'm new to ASP.net, SQL Server and visual studio.net, and I'm having problem inserting and storing data from a web form to a SQL database. I created a simple ASP.NET web form, a simple SQL...
3
by: romayankin | last post by:
I'm trying to create PHP trim() function equivalent using pure JS code that truncates spaces from the begging and from the end of the given string. One of the solutions is to use two "while" loops...
1
by: MaRkHaSBEEnMade | last post by:
Hi there I currently have a listbox that displays provinces,regions and suburbs.I want to pad the items logically with spaces,but the spaces are being igonred... eg Province1 ...
2
by: dachrist28 | last post by:
I am trying to populate a listbox with data that is pulled from a sql query. Here is my C# code behind the page: sqlConn1.Open(); SqlCommand sqlComm2 = new SqlCommand("SElECT...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.