I am trying to click into cells of a Listbox but I meet a problem of “quality”.
So I have a Listbox where the cells are filled with different pictures by mean of CellBackgroundPaint.
By clicking on a cell I put a different picture in that one by mean of CellTextPaint.
Even with a “Return True” at the end of those functions a white rectangle is drawn around the whole selected Row.
Without using “Return True” the Row is highlighted.
Is it possible to avoid that white rectangle?
I had another question regarding this.
To avoid that problem I wanted to put an empty Canvas in front of the ListBox and put all the mouse actions in that Canvas.
But when I click in the Canvas it works only outside the ListBox.
Is it possible to declare the Canvas in front of the ListBox?
Thanks to you.
Do it all in the listbox. Handle the click in Listbox.MouseDown using Listbox.RowFromXY and Listbox.ColumnFrom XY to know which cell was clicked.
Did you read: Listbox ?
If so, you read about CellBackgroundPaint.
You will also know what that white rectangle is (a TextEdit: a place to set Texts in the Cell).
At last, a check (Search) in this forum will return useful (I hope) information.
Thank you Karen,
I miss certainly something in your explanation but in my understanding your proposal is another way to get the row and column values of one cell but my problem is remaining.
If I take the liberty to ask this question, it is because I have spent a lot of time to solve that “small problem” by searching in the forum and on internet.
When I speak about a white rectangle it is not a TextEdit but a rectangle (wire) around all the cells of the Row.
Plutt que de prendre les gens pour des cons essaie au moins de comprendre ce que j’ai crit.
Je n’ai pas besoin de relire la thorie, je sais qu’on n’y dit pas comment viter qu’un bte rectangle blanc ne s’affiche autour des cases d’une range quand on clique dessus!
J’espre que quelqu’un de plus comptent pourra m’aider.
Thanks for your help.
Be more expressive / descrioptive in what you’ve done and what you want to achieve.
For example “the white rectangles” in a row: beside Cells, I do not know what they can be.
Doh ! Is your rectangle a “primtre” ? (empty inside)
In that case, this can be a Focus “ring” you set around the row (no focus ring with Windows).
And, do a screen shot and put it in this page will let us better understan your trouble (maybe).
If you return true in mousedown and don’t implement the drag events, the listbox acts as if there was no click at all, except for what you do in code… so the problem should go away.
Hi Benoit. In your CellBackgroundPaint event you need to fully clear the whole area before you paint a picture or you will end up with artefacts when you select the cell/row.
Function CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) Handles CellBackgroundPaint as Boolean
g.ForeColor = &cffffff
g.FillRect(0, 0, g.width, g.height)
Here’s an example:
Let me know if it does/doesn’t help, if it doesn’t, I might need a picture or further explanation of the problem.
In the WIndow Editor, place the
Canvas inside the
Listbox boundaries (and the Listbox will get a surrounding red rectangle when the Canvas is selected).
Canvas1.Parent = Listbox1
In the documentation:
Thank you my friends, I will try your different proposals and come back soon.
In facts I have two problems. I work with two ListBoxes.
I would like to move the content (picture) from one cell of the first Listbox to another Cell of the second Listbox by clicking on a Cell in the first Listbox and drag (move) that picture towards the second Listbox.
So I am trying to put the picture in the MouseCursor or in a moving Canvas.
The simpliest way I see to do that is to put a transparent Canvas covering both Listboxes without being sure of the final result.
That’s right Emile it is a “primtre” corresponding to a focus when I click in a cell.
By clicking in a cell I directly set the focus to another Textfield for example, it works well but if I click to fast in different Cells the picture that I will move from one Cell to another one remains in certains Cells.
I could be satisfied by the result I get know but I would like that this moving of picture is really “clean”.
Julian I am sorry (I am not an expert) but I don’t know how to open binary file.