Welcome Guest.   Make a donation to an author on the site November 28, 2014, 01:04:00 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Read the full one-year retrospective report on DonationCoder.com.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: ListBox Multi Selection Help  (Read 5220 times)
fmwyso
Participant
*
Posts: 5

View Profile Give some DonationCredits to this forum member
« on: November 08, 2008, 01:54:15 PM »

 Hey, I love C++ Builder and it has surpassed VC++ in every way so far...

 But there is currently one problem that I can't seem to find out... I need to get all the selected strings from a ListBox and I can't find out what function/variable I need to use to do so?

 What I want:

 An array/list of the strings that are selected inside of a listbox. (Or the indexes of them, I know how to do for loops and how to grab the string at a certain index).

 Any help is appreciated (Even a forum where the answer may be easier to get),

   fmwyso
Logged
mouser
First Author
Administrator
*****
Posts: 33,703



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: November 08, 2008, 02:57:34 PM »

The TCheckListBox component has a property called "State" which is indexed by the item number, and returns cbChecked if its checked, or cbUnchecked if not.

so for example if you have
Formatted for C++ with the GeSHI Syntax Highlighter [copy or print]
  1. TCheckListBox *mylistbox;

and you want to see what items are checked you could do

Formatted for C++ with the GeSHI Syntax Highlighter [copy or print]
  1. for (int i=0;i<mylistbox->Items->Count;++i)
  2. {
  3.  if (mylistbox->State[i]==cbChecked)
  4.    {
  5.    // item #i is checked
  6.    }
  7. }
Logged
fmwyso
Participant
*
Posts: 5

View Profile Give some DonationCredits to this forum member
« Reply #2 on: November 08, 2008, 03:54:02 PM »

 Hey, I checked over the variables again to look for something that was like State... and Found Selected which I apparently tried wrongly before ><... But now I got it working and thanks cheesy

 Thanks for your help,

  fmwyso
« Last Edit: November 08, 2008, 03:59:31 PM by fmwyso » Logged
mouser
First Author
Administrator
*****
Posts: 33,703



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: November 08, 2008, 03:58:27 PM »

sorry i misread.  You can do *exact* same thing just use the property Selected[i] which returns true if it is selected.
Logged
fmwyso
Participant
*
Posts: 5

View Profile Give some DonationCredits to this forum member
« Reply #4 on: November 08, 2008, 04:00:12 PM »

 xD, just edited last post... I coulda swore I tried the selected... But i think i used the parenthesis instead of brackets ><.

 Thanks for your help tongue.
Logged
K.Sagar
Participant
*
Posts: 1

View Profile Give some DonationCredits to this forum member
« Reply #5 on: August 13, 2009, 01:42:20 AM »

Hi,
I am using TList for collection of objects. When my List index do not contain any object it returns me Index out of bound Exception. But I want to Check List before it gives exception.
Plz Help.
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.043s | Server load: 0.04 ]