DrawString through columns Listbox

Hello, I need to use the Listbox’s CellTextPaint event, in order to Draw a String, though the 5 columns of the table in a row.

I’m Using g.DrawString(String,0,g.textAscent, g.Width, False)

But only write the text on each cell

Any clues?

0 in your parameter is the Row nbr,

you forget to add the Cell number…

Are you wanting one long string to span the 5 columns?

If so then you will have to draw the same string in each column with the x position offset.
so… if your column widths were 50,100,75,25 your x offset for each column would be:
0,-50,-150,-225,-250

The LR says:

ListBox.CellTextPaint(g as Graphics, Row as Integer, Column as Integer, x as Integer, y as Integer) As Boolean

As I wrote earlier (I was in a hurry), you passed the Row #, but not the Column #.

@Karen Atkocius has a product for this have a look at http://www.katkosoft.com/Mergeable%20Listbox%20Page/MergeableCellListbox.html

[quote=395735:@Emile Schwarz]The LR says:

ListBox.CellTextPaint(g as Graphics, Row as Integer, Column as Integer, x as Integer, y as Integer) As Boolean

As I wrote earlier (I was in a hurry), you passed the Row #, but not the Column #.[/quote]
That’s an event Emile, not a method.

Gerardo wrote:

And I say he forget the Column value.

Now I do not understand.

Yes, that I want to do is write a Text that cross all the columns, simulating Merged cells.

If I use a select case of a column, the text will be in one column, if not, the text will be written on each cell of the row, and I don’t like that

[quote=395731:@Kevin Gale]Are you wanting one long string to span the 5 columns?

If so then you will have to draw the same string in each column with the x position offset.
so… if your column widths were 50,100,75,25 your x offset for each column would be:
0,-50,-150,-225,-250[/quote]
It sound good, I’ll gonna try

So you want to simulate a Cell that span in many columns…

in html, I coded that <td span=5 …>Text data here</td>.

[quote=395814:@Emile Schwarz]So you want to simulate a Cell that span in many columns…

in html, I coded that <td span=5 …>Text data here</td>.[/quote]
Emile… just what does doing in HTML have to do with doing it with a Xojo Listbox?

Nothing. A simple example/question to be sure of what was asked…
It was not an answer. / It was not clear (to me) what was asked.

[quote=395765:@Emile Schwarz]Gerardo wrote:

And I say he forget the Column value.
Now I do not understand.[/quote]
The DrawString method of the Graphics class doesn’t have a “column” parameter. I think you confused Graphics.DrawString and Listbox.CellTextPaint.

Hi Greg,

I think you are right: I read the Event definition (with Row and Column) and the g.DrawString and do a mix in my brain. If I tested the idea I would realize the error.

Thanks.