Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write into combobox

Status
Not open for further replies.

nanzp

Programmer
Feb 24, 2000
10
0
0
IE
Hi all,<br>
I am using a combo-box in a dialog-box where the user selects Insert mode, Update mode or View mode. If the user selects Insert mode I want them to be able to write into the combo-box rather than selecting from it.<br>
Does anyone know the code to get the text that the user types into the combo-box.<br>
I cannot see how an index is assigned to the new item that the user types in.<br>
Thanks in advance,<br>
Ann
 
Hi Ann,<br>
Use the InsertString Method:<br>
<br>
InsertString(nIndex, String);<br>
<br>
Index is the zero based index position in the combobox that<br>
will recieve the string.<br>
<br>
String is the string or variable holding the string that you want to write.<br>
<br>
if you have a set zero based scale that you don't want to change then you will have to set up a counter, such as <br>
x = x + 1 to dictate the index, where x = nIndex, otherwise the new item will be added to the zero position each time.
 
or may be you can try using AddString(String);<br>
it will add a string at the zero based index position<br>
for the first time, and after that a call to AddString(String) just appends it to the list.<br>
And you can use this piece of code to keep the last item currently selected.<br>
<br>
int nCount = pmyComboBox-&gt;GetCount();<br>
if (nCount &gt; 0)<br>
pmyComboBox-&gt;SetCurSel(nCount-1);<br>
You have to do (nCount-1) cos the index of combobox is zerobased<br>
<br>
All the best
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top