New topic: Listbox/Checkbox Question
<http://forums.realsoftware.com/viewtopic.php?t=44020> Page 1 of 1 [ 14 posts ] Previous topic | Next topic Author Message jerryab Post subject: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 11:46 am Joined: Mon Dec 12, 2011 7:25 pm Posts: 14 Location: Grand Rapids MI Area I have a listbox with checkboxes. Is there a way to get an index number of the check box? What I am trying to do is when you check a checkbox I want to save the item in the listbox (beside the checkbox) to a database. Checkbox | Listbox Item --------------------------------------------------------- checked | Full Name = Save/Update the item in the database unchecked | Full Name = Save/Update the item in the database I can't seem to get the hightlighted item to follow the checkbox when it gets clicked. Is the checkbox index the same as the listbox index ? I hope i explained this enough. _________________ iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Lion 10.7.3 Toshiba Laptop Running Windows 7 & WinXP SP3 REAL Studio Enterprise Edition 2011r4.3 http://www.theultimatecampgroundlog.com Being rewritten for the Mac Top markwalsh Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 12:18 pm Joined: Wed May 20, 2009 4:43 pm Posts: 795 Loop through the rows in the listbox, and check the cell's CellState for the cell which has the checkbox to determine which rows are checked. _________________ RB 2009r4 Windows XP Top DaveS Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 12:19 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 3693 Location: San Diego, CA in the CELLACTION event of the listbox Dim flag As Boolean flag=Me.CellCheck(row,column) sql="UPDATE patients set IS_SELECTED="+OUTPUT_BOOLEAN(flag)+" WHERE patient_id="+Me.rowtag(row) Call DB_Execute(sql,False) this is an example from a program of mine where I store the checked value in a database field called IS_SELECTED... the ROWTAG of the listbox contains the database key value NOTE : NO NEED TO LOOP THROUGH THE ROWS _________________ Dave Sisemore MacPro, OSX 10.7.3 RB2011r3 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top jerryab Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 1:42 pm Joined: Mon Dec 12, 2011 7:25 pm Posts: 14 Location: Grand Rapids MI Area Thanks for the reply guys. But I only want to update the the checkbox checked not all checkboxes. Daves Your idea is close but with yours you have a known id. If I could get the row highlighted that the checkbox is in when you check/uncheck the box I would have the ID needed to write the database. Any idea on how to get the row highlighted BESIDE the checkbox when clicked on ? _________________ iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Lion 10.7.3 Toshiba Laptop Running Windows 7 & WinXP SP3 REAL Studio Enterprise Edition 2011r4.3 http://www.theultimatecampgroundlog.com Being rewritten for the Mac Top timhare Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 1:51 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 11307 Location: Portland, OR USA You're passed the row number: ROW as Integer. It is also available in ListIndex. Top jerryab Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 1:56 pm Joined: Mon Dec 12, 2011 7:25 pm Posts: 14 Location: Grand Rapids MI Area Hi, Timhare I am new to RS, can you explain that a little more please ? _________________ iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Lion 10.7.3 Toshiba Laptop Running Windows 7 & WinXP SP3 REAL Studio Enterprise Edition 2011r4.3 http://www.theultimatecampgroundlog.com Being rewritten for the Mac Top DaveS Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 2:03 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 3693 Location: San Diego, CA when you populate the Listbox... you place the Database Key value in the ROWTAG for each row When you click on a row, the ACTION event knows what row you clicked on, you retrieve the ROWTAG and update the database depending on the CHECKBOX status. LISTINDEX is the row that is CURRENTLY selected (if it is -1 then no rows are selected) _________________ Dave Sisemore MacPro, OSX 10.7.3 RB2011r3 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top jerryab Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 2:30 pm Joined: Mon Dec 12, 2011 7:25 pm Posts: 14 Location: Grand Rapids MI Area Thanks for the help guys but it's not working. When I click on a checkbox the checkbox does get checked but the listbox highlighting never moves, it stays on item zero. It always gets the highlighted item as the index as it should. Lets say i have 5 items in a listbox and 5 checkboxes beside them on the left side of the item listed. When I click on the second checkbox the listbox still only gets the first items index. not the second one. Do I have to have more than one column when using the checkboxes? I'm using this code to add checkboxes to the list boxes but only have one column in the listbox. Is that the right way to do this? '// Creates Checkboxes in the NameListListbox 'NameListListbox.ColumnType(0) = Listbox.TypeCheckbox _________________ iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Lion 10.7.3 Toshiba Laptop Running Windows 7 & WinXP SP3 REAL Studio Enterprise Edition 2011r4.3 http://www.theultimatecampgroundlog.com Being rewritten for the Mac Top markwalsh Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 2:35 pm Joined: Wed May 20, 2009 4:43 pm Posts: 795 jerryab wrote:Thanks for the help guys but it's not working. When I click on a checkbox the checkbox does get checked but the listbox highlighting never moves, it stays on item zero. It always gets the highlighted item as the index as it should. Lets say i have 5 items in a listbox and 5 checkboxes beside them on the left side of the item listed. When I click on the second checkbox the listbox still only gets the first items index. not the second one. Do I have to have more than one column when using the checkboxes? I'm using this code to add checkboxes to the list boxes but only have one column in the listbox. Is that the right way to do this? '// Creates Checkboxes in the NameListListbox 'NameListListbox.ColumnType(0) = Listbox.TypeCheckbox Clicking on a checkbox cell does not automatically change the listbox selection. If you want to do that, you need to add code to the CellAction event to select that row. _________________ RB 2009r4 Windows XP Top jerryab Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 2:39 pm Joined: Mon Dec 12, 2011 7:25 pm Posts: 14 Location: Grand Rapids MI Area Thats what I have been trying to do but not sure how to do it. I can't seem to get an index from the checkboxes to move the listbox highlighting to the same row as the checkbox that was checked. _________________ iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Lion 10.7.3 Toshiba Laptop Running Windows 7 & WinXP SP3 REAL Studio Enterprise Edition 2011r4.3 http://www.theultimatecampgroundlog.com Being rewritten for the Mac Top markwalsh Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 2:44 pm Joined: Wed May 20, 2009 4:43 pm Posts: 795 jerryab wrote:Thats what I have been trying to do but not sure how to do it. I can't seem to get an index from the checkboxes to move the listbox highlighting to the same row as the checkbox that was checked. me.selected(row) = true You may need to loop through the listbox first setting selected false for each row (On my machine, even if the listbox is set to allow only a single row selection, it will select multiples when setting selected to true in the CellAction event - is this a bug?) _________________ RB 2009r4 Windows XP Top jerryab Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 3:01 pm Joined: Mon Dec 12, 2011 7:25 pm Posts: 14 Location: Grand Rapids MI Area Well I guess the check boxes aren't going to work for me then. The check boxes were going to be a way to tell me if I did a task or not. Check ment I did the tast, unchecked ment not. The listbox contains the key for the database I was going to write to so I needed the key information from the row beside the checkbox to write it. If I had to clear all the check boxes to find one checked one that defeats what I wanted to do. Anyway, Thanks for the replies guys. _________________ iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Lion 10.7.3 Toshiba Laptop Running Windows 7 & WinXP SP3 REAL Studio Enterprise Edition 2011r4.3 http://www.theultimatecampgroundlog.com Being rewritten for the Mac Top markwalsh Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 3:04 pm Joined: Wed May 20, 2009 4:43 pm Posts: 795 jerryab wrote:Well I guess the check boxes aren't going to work for me then. The check boxes were going to be a way to tell me if I did a task or not. Check ment I did the tast, unchecked ment not. The listbox contains the key for the database I was going to write to so I needed the key information from the row beside the checkbox to write it. If I had to clear all the check boxes to find one checked one that defeats what I wanted to do. Anyway, Thanks for the replies guys. You don't need to clear the checkboxes, but you may need to clear the selected property if you only want to have a single row selected. _________________ RB 2009r4 Windows XP Top DaveS Post subject: Re: Listbox/Checkbox QuestionPosted: Tue May 15, 2012 3:15 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 3693 Location: San Diego, CA Have you paid ANY attention to the ACTION event? It tells you EXACTLY what row was checked/unchecked... Are you using ROWTAG to hold your database key? If the answer to any of these questions is no.... then you have been ignoring all the advice we have been giving you. If the answer is yes.. post the exact code you are using (and the Event that it is in) because if what we told you isn't working.. you are doing something wrong. But if you decide you just want to give up... then we cannot help you.... _________________ Dave Sisemore MacPro, OSX 10.7.3 RB2011r3 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 14 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]
