cox8355
asked on
Clearing MFC Combo Box for repopulating
I have a combo box whose displayed list is dependent upon another user selection. When the user makes the selection,
the code:
ModelCount = m_modelCombo.GetCount();
for (i=0; i<ModelCount; i++)
m_modelCombo.DeleteString( i);
is executed. The combo box "m_modelCombo" is the given new values through the AddString method.
The new values are being displayed, but the previous values are partially left over, and the list continues to grow with each update attempt. What am i missing?
Randy
the code:
ModelCount = m_modelCombo.GetCount();
for (i=0; i<ModelCount; i++)
m_modelCombo.DeleteString(
is executed. The combo box "m_modelCombo" is the given new values through the AddString method.
The new values are being displayed, but the previous values are partially left over, and the list continues to grow with each update attempt. What am i missing?
Randy
hi
Instead of using AddString; use InsertString.
for (int i=0; i<m_combo1.GetCount(); i++)
m_combo1.DeleteString(i);
m_combo1.InsertString(0,"* .iii");
m_combo1.InsertString(1,"* .kkk");
That shall do the work for you
Instead of using AddString; use InsertString.
for (int i=0; i<m_combo1.GetCount(); i++)
m_combo1.DeleteString(i);
m_combo1.InsertString(0,"*
m_combo1.InsertString(1,"*
That shall do the work for you
ASKER
Thanks...but...tried both of these, but the problem remains. Portions of the previous list still linger after supposedly being deleted. For example, this is what typically happens:
First list: Second list: ...etc.
1st_Item_1 2nd_Item_1
1st_Item_2 2nd_Item_2
1st_Item_3 2nd_Item_3
1st_Item_4 2nd_Item_4
1st_Item_5 2nd_Item_5
1st_Item_2
1st_Item_4
Any other ideas?
Thanks
First list: Second list: ...etc.
1st_Item_1 2nd_Item_1
1st_Item_2 2nd_Item_2
1st_Item_3 2nd_Item_3
1st_Item_4 2nd_Item_4
1st_Item_5 2nd_Item_5
1st_Item_2
1st_Item_4
Any other ideas?
Thanks
This codes works perfectly well
Check it out
int temp=m_combo1.GetCount();
int text1;
for(int i=temp;i>=0;--i)
text1=m_combo1.DeleteStrin
m_combo1.InsertString(0,"h
m_combo1.InsertString(1,"h
m_combo1.SetCurSel(0);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
Still somewhat of a mystery for this reason...I was going from element 0 to (GetCount-1), where your loop was (GetCount) to 0.
I thought if GetCount returned, say, 10, that the elements would be referenced from 0 to 9. Your loop deletes elements 10 through 0....one more than it seems it should...??? Maybe I'm missing something that I'll see later...but it works.
Many thanks,
Randy
Still somewhat of a mystery for this reason...I was going from element 0 to (GetCount-1), where your loop was (GetCount) to 0.
I thought if GetCount returned, say, 10, that the elements would be referenced from 0 to 9. Your loop deletes elements 10 through 0....one more than it seems it should...??? Maybe I'm missing something that I'll see later...but it works.
Many thanks,
Randy
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:
Answered: Points split between subhadeepin and LSkywalker
Please leave any comments here within the next seven days.
Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (https://www.experts-exchange.com/help.jsp#hi73).
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
-bcl (bcladd)
EE Cleanup Volunteer
leave a recommendation in the Cleanup topic area that this question is:
Answered: Points split between subhadeepin and LSkywalker
Please leave any comments here within the next seven days.
Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (https://www.experts-exchange.com/help.jsp#hi73).
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
-bcl (bcladd)
EE Cleanup Volunteer
Jon