Real Software Forums
http://forums.realsoftware.com/

Split One row into 2 lines into listbox
http://forums.realsoftware.com/viewtopic.php?f=23&t=48017
Page 1 of 1

Author:  fernandopm [ Wed May 29, 2013 11:50 pm ]
Post subject:  Split One row into 2 lines into listbox

I need split one record into 2 lines of my listbox
My code is:

Listlogros.addrow (rs.Field("CODIGO1").StringValue, rs.Field("EQUIPO1").StringValue, rs.Field("MLA").StringValue, rs.Field("CODIGO2").StringValue, rs.Field("EQUIPO2").StringValue, rs.Field("MLB").StringValue)

I need display one row in two lines display

CODIGO1 EQUIPO1
CODIGO2 EQUIPO2

.........
.........

.
Next Record

Author:  Joshua Janssen [ Thu May 30, 2013 12:28 am ]
Post subject:  Re: Split One row into 2 lines into listbox

Hi FernandoPM

Not sure whether this will help, but is this what you mean?

while not rs.eof
listlogros.addrow rs.field("CODIGO1").Stringvalue,rs.Field("EQUIPO1").StringValue, rs.Field("MLA").StringValue
listlogros.addrow rs.Field("CODIGO2").StringValue, rs.Field("EQUIPO2").StringValue, rs.Field("MLB").StringValue

rs.movenext
wend


Regards,
Josh

Author:  Akiland [ Thu May 30, 2013 12:31 am ]
Post subject:  Re: Split One row into 2 lines into listbox

If you need two lines in one row you can put an EndOfLine in there.
ListBox1.AddRow "Hello" + EndOfLine + "World"

So in your case it would be something like:
Listlogros.addrow (rs.Field("CODIGO1").StringValue, rs.Field("EQUIPO1").StringValue, rs.Field("MLA").StringValue + EndOfLine, rs.Field("CODIGO2").StringValue, rs.Field("EQUIPO2").StringValue, rs.Field("MLB").StringValue)

Author:  fernandopm [ Thu May 30, 2013 1:45 am ]
Post subject:  Re: Split One row into 2 lines into listbox

Akiland wrote:
If you need two lines in one row you can put an EndOfLine in there.
ListBox1.AddRow "Hello" + EndOfLine + "World"

So in your case it would be something like:
Listlogros.addrow (rs.Field("CODIGO1").StringValue, rs.Field("EQUIPO1").StringValue, rs.Field("MLA").StringValue + EndOfLine, rs.Field("CODIGO2").StringValue, rs.Field("EQUIPO2").StringValue, rs.Field("MLB").StringValue)


EndOfLine is Operator Incompatible

Author:  Akiland [ Thu May 30, 2013 3:02 am ]
Post subject:  Re: Split One row into 2 lines into listbox

Works for me :)
Image
ListBox1.AddRow "Hello" + EndOfLine + "World"

Author:  fernandopm [ Thu May 30, 2013 3:12 am ]
Post subject:  Re: Split One row into 2 lines into listbox

Akiland wrote:
Works for me :)
Image
ListBox1.AddRow "Hello" + EndOfLine + "World"

Yes, is work with string,but fields not

In it case:
Listlogros.addrow (rs.Field("CODIGO1").StringValue, rs.Field("EQUIPO1").StringValue, rs.Field("MLA").StringValue + EndOfLine, rs.Field("CODIGO2").StringValue, rs.Field("EQUIPO2").StringValue, rs.Field("MLB").StringValue)

Author:  Akiland [ Thu May 30, 2013 3:20 am ]
Post subject:  Re: Split One row into 2 lines into listbox

aah, sorry it don't seem to work when you're populating multiple columns.
hmm..tricky

Author:  Jason_Adams [ Thu May 30, 2013 9:12 am ]
Post subject:  Re: Split One row into 2 lines into listbox

Just in case you really need this to work and you can't discern a way to do it with the WebListBox, you could try the WebListBoxTD from Web Custom Controls.

Author:  timhare [ Thu May 30, 2013 11:21 am ]
Post subject:  Re: Split One row into 2 lines into listbox

fernandopm wrote:
Yes, is work with string,but fields not

In it case:
Listlogros.addrow (rs.Field("CODIGO1").StringValue, rs.Field("EQUIPO1").StringValue, rs.Field("MLA").StringValue + EndOfLine, rs.Field("CODIGO2").StringValue, rs.Field("EQUIPO2").StringValue, rs.Field("MLB").StringValue)

You're adding an endofline, but not using it. I recommend you simplify your addrow code, get it working, then build it back up. Also, it helps to use local variables, so you can see what is happening.

Oh wait, I think I see what you're trying to do now. You need to address each column separately. Try this:

dim column1, column2, column3 as string
column1 = rs.Field("CODIGO1").StringValue + EndOfLine + rs.Field("CODIGO2").StringValue
column2 = rs.Field("EQUIPO1").StringValue + EndOfLine + rs.Field("EQUIPO2").StringValue
column3 = rs.Field("MLA").StringValue + EndOfLine + rs.Field("MLB").StringValue
Listlogros.addrow(column1, column2, column3)

Author:  taylor-design [ Thu May 30, 2013 11:58 am ]
Post subject:  Re: Split One row into 2 lines into listbox

While I would love for you to check out Web Custom Controls (thanks Jason!), I am able to use EndOfLine with a multi-column WebListBox and RecordSet fields in 2012r2.1. Here's the code from a test project (WebListBox, WebButton, code is in the button)

Dim rs As RecordSet = ef.SQLSelect("select * from test")

While rs.EOF = False
cnList.AddRow(rs.Field("test1").StringValue + EndOfLine + rs.Field("test2").StringValue, _
rs.Field("test1").StringValue + EndOfLine)
rs.MoveNext
Wend


Image

Note that the second column text appears centered vertically because there is no text after EndOfLine. Even adding a space doesn't force it to align with the first column. There might be some other blank character you can use.

Also: I would test the display on each browser to make sure that the EndOfLine character(s) are interpreted correctly.

If you need more complex formatting, Web Custom Controls lets you put whatever HTML you like into a cell.

Author:  taylor-design [ Thu May 30, 2013 12:04 pm ]
Post subject:  Re: Split One row into 2 lines into listbox

timhare wrote:
Also, it helps to use local variables, so you can see what is happening.


One of the best pieces of advice you can give. Though I didn't do it in the example above, in my working code I error on the side of over using local variables. I prefer each line to do one clearly visible thing.

I find it helps with debugging and with re-engineering code later on.

Author:  silverpie [ Thu May 30, 2013 3:25 pm ]
Post subject:  Re: Split One row into 2 lines into listbox

taylor-design wrote:
Note that the second column text appears centered vertically because there is no text after EndOfLine. Even adding a space doesn't force it to align with the first column. There might be some other blank character you can use.


Try &uA0, the non-breaking space (equivalent of the   entity in HTML).

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/