Celltextpaint & Ms Excel help


I have a listbox with a thousand rows.
I want to inserting text into specific criteria onto it, by adding some code in celltextpaint event.

The code seems to works, but the problem isI have to scroll it down manually by clicking the scrollbar button.

my question is, how to keep the text there without scrolling manually.

And also I tried to exporting into an excel spreadsheet, the correct result only for the first 15 rows which is shown on the listbox.

I am sure the problem is coming from this celltextpaint which is not refresh automatically.
is there any other ways to handle this method?, I have tried to do it in a button, but does not work.

any help…


Are you adding the data in the listbox via CellTextPaint or are you adding the data with AddRow and CellValueAt? It sounds like you aren’t really putting the data into the listbox cells, but rather just painting the values on demand.

yes, I do adding the data via celltextpaint.
The Listbox has some data, but I want to add some text using celltextpaint method.

how to change this code by using CellValueAt, I have check The LR, but its not describe completely

here is the code,

if Listbox1.cell(row,0)=" " then
  dim gg as integer
  //calculate total start
  dim total as double
  Dim xRow,nRow,oCount As Integer
  dim oo as integer
  for oo=0 to Listbox1.ListCount -1
    dim ggg,j,ah as integer
    dim cd as integer
  For nRow=0 to xRow-1
    Dim s,ss As String
    If s=Listbox1.cell(row,0) Then
      total = total + CDbl(Listbox1.Cell(nrow, 5).Trim)
    end if
    Listbox1.cell(row,12)= str(total)


CellValueAt is the new version (API2) of Cell that you are using.

I’m not clear on what you are trying to add with CellTextPaint though? You’d only want to use this to change the rendering of the text that is already in the cell. You could change the content, but you need to content for other purposes (like the Excel export). What are you doing in CellTextPaint?

The data is come from a csv file.
My goals is converting the data in listbox with some modification in celltextpaint event and exporting the result into an excel sheet without scrolling the list box manually.


It sounds like you don’t need to use CellTextPaint since display is not your primary objective. You may not even need a listbox (do you even need to look at the data? If not, working with the data in an array in memory may be faster).Iff you do use a listbox, you should be able to add additional columns to the listbox and place the modified values in those columns, or just update the data in place in the cells. You would use CellValueAt for getting and setting the values in your data processing function.
CellTextPaint is only used to modify how the text in the cell is rendered. It is only triggered for a cell when that cell is painted (along with CellBackgroundPaint), which only occurs when the cell is visible and needs to be redrawn. You should not perform processing in this event.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.