New topic: Change color of ListBox cell on Double Click
<http://forums.realsoftware.com/viewtopic.php?t=46513> Page 1 of 1 [ 7 posts ] Previous topic | Next topic Author Message simulanics Post subject: Change color of ListBox cell on Double ClickPosted: Thu Jan 10, 2013 12:08 pm Joined: Sun Aug 12, 2007 10:10 am Posts: 970 Location: Boiling Springs, SC Ok. I'm aware of how to change row color and cells by row,column on first Open of the application using CellBackgroundPaint and I have combed through the forums... the only potential solution is no longer available "Mergeable Cell Listbox"... Could someone post an example of how to do this? I want to DOUBLECLICK a cell and change its background color. Don't bother searching the forums, there are no examples...have looked...and me.activecell.background is no help. Thanks _________________ Matthew A. Combatti Real Studio 2012 r1.2 Visit Real Studio Developer's Spot! Systems I Use: Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Beta Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/ Windows Server 2011/CentOS 5.4 /ReactOS/SimOS ~All REAL Compatible~ Top markwalsh Post subject: Re: Change color of ListBox cell on Double ClickPosted: Thu Jan 10, 2013 1:38 pm Joined: Wed May 20, 2009 4:43 pm Posts: 920 simulanics wrote:Ok. I'm aware of how to change row color and cells by row,column on first Open of the application using CellBackgroundPaint and I have combed through the forums... the only potential solution is no longer available "Mergeable Cell Listbox"... Could someone post an example of how to do this? I want to DOUBLECLICK a cell and change its background color. Don't bother searching the forums, there are no examples...have looked...and me.activecell.background is no help. Thanks Why not just set a flag in the cell's celltag property, and check that in CellBackgroundPaint? Function CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean If (row > Me.ListCount-1) Or (row < 0 )Then ' Invalid row, return Return false End If If (column > Me.ColumnCount - 1) Or (column < 0 )Then ' Invalid column, return Return false End If if me.celltag(row, 0) then g.ForeColor = RGB(200, 100, 100) g.FillRect (0, 0, g.Width, g.Height) return true end if End Function Sub DoubleClick() Dim row as integer Dim column as integer row = Me.RowFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top) column = Me.columnFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top) If (row > Me.ListCount-1) Or (row < 0 )Then ' Invalid row, return Return End If If (column > Me.ColumnCount - 1) Or (column < 0 )Then ' Invalid column, return Return End If me.cellTag(row, column) = NOT me.cellTag(row, column) End Sub _________________ RB 2009r4 Windows XP Top elChupete Post subject: Re: Change color of ListBox cell on Double ClickPosted: Thu Jan 10, 2013 1:51 pm Joined: Fri Jun 05, 2009 11:50 am Posts: 326 Location: Hamburg, Germany just a quick not tested idea in cell.click event start a timer (timername = listbox+rowid+columnid timer modesingle period time between two clicks (if you know any other way to identify double clicked cell, use that one. I fear that listbox.doubleclick event might not help as it only knows listbox has been double clicked and does not know which cell). action event of timer would not do anything. before timer is started check timer.enabled, if true timer is running and user has double clicked cell. in that case set cell.tag to the string representation of the color you want the cell (e.g. "red", "blue" etc.) be painted. in cellbackgroundpaint event, read cell.tag and draw backround colour the way you want it _________________ Best regards Stefan Mac OSX 10.8.1 on a MacBook Pro 2.66 GHz Intel Core i7/ RB Professional 2011 Release 3 Top p0wn3d Post subject: Re: Change color of ListBox cell on Double ClickPosted: Thu Jan 10, 2013 1:52 pm Joined: Sun Oct 28, 2012 4:54 am Posts: 69 Location: Herts, UK This might help, crude and knocked up quickly... http://justgoodit.eu5.org/rb/cellcolor.zip _________________ Real Studio 2012 R2 SysInfo BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD Top jakuno Post subject: Re: Change color of ListBox cell on Double ClickPosted: Thu Jan 10, 2013 2:19 pm Joined: Fri Aug 31, 2012 3:56 pm Posts: 61 try: https://dl.dropbox.com/u/103694210/ListBoxColor.rbp.zip Top p0wn3d Post subject: Re: Change color of ListBox cell on Double ClickPosted: Thu Jan 10, 2013 2:22 pm Joined: Sun Oct 28, 2012 4:54 am Posts: 69 Location: Herts, UK Thanks jakuno been trying to do this too... _________________ Real Studio 2012 R2 SysInfo BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD Top simulanics Post subject: Re: Change color of ListBox cell on Double ClickPosted: Thu Jan 10, 2013 3:01 pm Joined: Sun Aug 12, 2007 10:10 am Posts: 970 Location: Boiling Springs, SC Many thanks everyone _________________ Matthew A. Combatti Real Studio 2012 r1.2 Visit Real Studio Developer's Spot! Systems I Use: Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8 Beta Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/ Windows Server 2011/CentOS 5.4 /ReactOS/SimOS ~All REAL Compatible~ Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 7 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]
