format cell of listbox

I do the following:
enter a value in a cell
hit Enter key
format the text of the cell like me.text = format(val(me.text),"-0.00")
redisplay text.

If possible I would repaint with color or bold or whatever.

In case of an input with textfields I use containers and addhandler.

Do that in CellTextPaint: List of Events

Bold ?

Check also the documentation.

I checked documentation the whole day. Can’t find anything relevant.
It can’t be that difficult
I tried this in ‘CellTextPaint’ but nothing happens

if row = me.LastIndex then select case column case 13 me.Text = format(val(me.Text),"###0.00") return True end select end If
Isn’t there anybody that can give me an example?

[code]Function CellTextPaint(g As Graphics, row As Integer, column As Integer, x as Integer, y as Integer) As Boolean
if val(me.cell(row,column)) < 0 then
g.ForeColor = &cFF0000
else
g.ForeColor = &c000000
end if

End Function
[/code]

That is what I understand. This puts the number in red
But how can I enter a number, do some formatting like decimals and put it back in the cell formatted.

Example:
Input is 12.5
do something like me.text = format(val(me.text),"-0.00")
result: 12.50
after Carriage Return

Function CellKeyDown(row as Integer, column as Integer, key as String) As Boolean
’ select case column
’ case 1

if key = chr(13) or key = chr(3) then
dim dVal as Double = CDbl(me.ActiveCell.Text)
me.ActiveCell.Text = Format(dVal,"-###.00")
end if

’ end Select
End Function

1 Like

That did it. The magic word ActiveCell.
Thanks very much Adreas
and of course the others too

Roland