Thread: Using Checkboxlist items

  1. #1
    Registered User Aga^^'s Avatar
    Join Date
    Aug 2008
    Posts
    71

    Using Checkboxlist items

    i have a checkboxlist and there are items. In a row there are name + " " + surname. I want to get the only name value by usign checkboxlist class. How can i do that?

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    If it's a listview you can use the subitems[n].Text property. Otherwise see which items are checked (I believe theres a checkedItems property for listview and listbox), and then split the string on a " ".

  3. #3
    Registered User Aga^^'s Avatar
    Join Date
    Aug 2008
    Posts
    71
    thanks valaris.
    i did it
    Code:
            string kisi_name = cblNames.SelectedItem.ToString();
            char[] toSplit ={ ' ' };
            string[] words = kisi_name.Split(toSplit);
    
            words[0] is the name column which i wanted

  4. #4
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Split contains an overload for a single char or a string to match against. So you could more clearly write:

    Code:
    kisi_name.Split(" ");
    Also SelectedItem doesn't mean checked if I remember right. For instance a user could check some item then select another item. If by checked you just mean "selected/highlighted" then what you are doing is correct. There is checked property though on the item.

  5. #5
    Registered User Aga^^'s Avatar
    Join Date
    Aug 2008
    Posts
    71
    i did the part which you mentioned by saying " a user could check some item then select another item "
    thanks again valaris

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HELP!!!!emergency Problem~expert please help
    By unknowppl in forum C++ Programming
    Replies: 9
    Last Post: 08-21-2008, 06:41 PM
  2. HELP!!!!emergency ~expert please help
    By unknowppl in forum C Programming
    Replies: 1
    Last Post: 08-19-2008, 07:35 AM
  3. Retail Outlet Managment System - the 4th
    By Presidentofusa in forum C Programming
    Replies: 3
    Last Post: 11-10-2007, 10:44 PM
  4. scan multiple items in multidimensional array
    By requiem in forum C Programming
    Replies: 1
    Last Post: 04-17-2003, 03:02 PM
  5. CListView & Appending Items :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 04-28-2002, 11:37 AM