thanks
If I understand right, that draws the background of a whole cell.
I just want to have single words in acell coloured.
In my example the listbox has just 1 column
[quote=88703:@michael eder]thanks
If I understand right, that draws the background of a whole cell.
I just want to have single words in acell coloured.
In my example the listbox has just 1 column[/quote]
CellBackgroundPaint lets you draw whatever (and wherever) you want in the cell. That said since you are doing text I would suggest you draw the the text with word highlight in CellTextPaint.
You will just need to break the string into pieces and draw each piece any way you want. Use g.StringWidth to measure the pieces
how can I avoid to call n times AddRow for the numbers of rows I need, because I don’t want to show the cells context.
If I don’t call AddRows the CellTextPaint Event isn’t called.
[quote=88890:@michael eder]how can I avoid to call n times AddRow for the numbers of rows I need, because I don’t want to show the cells context.
If I don’t call AddRows the CellTextPaint Event isn’t called.[/quote]
I don’t think you can. I think the only way to set the number of rows in a Listbox is to use the AddRows method the number of times you need.
Why do you need a fixed number of rows? What do your users do with the blank rows?
You can’t have rows if you don’t add them. AddRow adds the row, without it there’s no row to have and render.
In the paint events for background and text you can control exactly what gets painted (which can be completely unrelated to the content) or that nothing is painted (return true without drawing anything).
If you want full control return true in CellTextPaint and do all the drawing (even text, if you wish) from within CellBackgroundPaint.