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?
Printable View
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?
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 " ".
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
Split contains an overload for a single char or a string to match against. So you could more clearly write:
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.Code:kisi_name.Split(" ");
i did the part which you mentioned by saying " a user could check some item then select another item "
thanks again valaris