Deletion of a string from List Box in MFC
Hi
I have a list box that contain following strings
text
book for C
book
civil
etc...
when I remove a particular string using following code 

int iSelCount=Listboxcntrl.FindString(0,book);
 Listboxcntrl.DeleteString(iSelCount);

it removed the first item that contain the word book
it removed the word book for C. I want to remove exactly book. Can anybody help?

See All Responses Below...
Author
Message Rating
Posted on: 03/03/2014
Hello,

Do it like this..

Iterate form last to fist using for loop
1. Check whether each item is selected.
2. get the LtstBox item text using GetLBText
3. If it matches, remove it..

Tom
Posted on: 03/03/2014
Thank you..

But I got the answer by FindStringExact() method

int iSelCount=Listboxcntrl.FindStringExact(0,book);
Listboxcntrl.DeleteString(iSelCount);

Share this page across other social networking sites



Please Login to Post Your Comments
Name (Max. 100 characters)
Please post your comments here
Select Language
Comments
Attach File(Max. Size: 2 MB)
A few simple rules when posting your Comments,
  1. Please post only answers relevant to the topic of discussion.
  2. Please dont misuse this site or do not be abusive, offensive, inappropriate,harass anyone on the boards or post ads or spam. Doing so will delete your inappropriate messages and will block or delete your account on this site.