My application is developig in VC++ 2008. I have a List Box. Where I am Loading some Text data from a text file. After Loaded the listBox is as show in the attached figure :
I have used it as a SINGLE SELECTION List Box. Here I would like to change as MULTILINE SELECTION so as to delete the selected List BOX datas.
For the Single Line Delete operation I have written the following code.
unsigned int len = m_parameterlist.GetCurSel();
len = m_parameterlist.GetCount();
len = len-1;
int current = m_parameterlist.DeleteString(len);
int newcnt = m_parameterlist.GetCount();
for(int i = 0;i < newcnt;i++)
m_parameterlist.GetText( i, str );
This has worked. The single line deleted and the remaining datas listed on ListBx But Now the User requirment got modified. I have changed the property to MULTILINE SELCTION. But the coding is confused.... Can u help me plz...
1. Your code is a little strange: what for are you using
2. To delete items in a listbox with multi-selection you have to call CListBox::GetSelItems , then sort the item indexes in a buffer and then delete selected items in a loop beginning from the max index.
Assembler is extremely different from GUI concepts..... While working on GUI based pgms,I have struggled several times n the CodeGurus like u helped me a lot... tats wy am here for getti ng it. I've tried the same example.. It gets the Count of Total selected items.But How to select particular indices for Delete????
As like the above said procedure..I've written the code as
int iTot = m_parameterlist.GetCount();
int newval=m_parameterlist.GetSelItems(len, arySel.GetData());
int current = m_parameterlist.DeleteString(i);
It deletes data..But not in order...Having some bugs...... Can anybody help to fix it????
Your question makes rethinking on me..
Bt after several try & error....... I reached here... n copied it here....
Ok.. So 1) how do I delete the exact Selected indexes....?
2)The return of . newval gets the Total Count of selected lines......!!!!!
got the logic..bt stucks some where......... ???