New topic: 

Listbox highlight row

<http://forums.realsoftware.com/viewtopic.php?t=35331>

         Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic          Author  
Message        spacewalker          Post subject: Listbox highlight rowPosted: 
Tue Sep 07, 2010 4:51 pm                         
Joined: Thu Nov 08, 2007 4:59 am
Posts: 331
Location: Germany                Hello,

I want to highlight the row where the mouse is over  (without mouse click)

I use the following code:

in the Listbox'  CellbackgroundPaint event:

Code:  if me.RowFromXY(me.MouseX-me.left,me.MouseY-me.top)=row then
  g.ForeColor=RGB(211,211,211)
  g.FillRect(0,0,g.Width,g.Height)
  return true
  end if
  

in mousemove:
  
  Code:dim r as integer
  r=me.RowFromXY(x,y)  //Zeile in der die Maus steht
  
  f r>-1 and r<me.ListCount then
  me.InvalidateCell(r,-1)
  if r>0 then me.InvalidateCell(r-1,-1)
  if r<me.ListCount-1 then me.InvalidateCell(r+1,-1)
  
  else
  me.InvalidateCell(-1,-1)
  end if
  
  
 Bascially this works but I have the problem that sometimes not only one row is 
highlighted but 3 or more rows.
 This seems to happen if I move the mouse quickly over the listbox and\or if I 
click into the listbox and then move the mouse...
 
 Can this be improved to be more reliable?
 
 thank you   
                             Top                timhare          Post subject: 
Re: Listbox highlight rowPosted: Tue Sep 07, 2010 5:37 pm                       
  
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 8268
Location: Portland, OR  USA                Save the row value in MouseMove and 
invalidate that on the next mousemove if it's different.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to