managing records in a combobox

S

Sam

Hi,
I have a datagrid which contains a combobox column bound to a
datatable(I'm using VS2003 but it's a custom control). For each of the
combobox I would like to achieve the same behaviour as for the font
selector in word, that is the most recent chosen fonts are added to the
top of the list.

Exemple:
Say your comboboxes contain the following values:
test0
test1
test2
test3

If in the grid the user chooses test0 on the first row and test2 on the
second row, then the comboboxes now show:
test0
test2
_____
test0
test1
test2
test3

How can I do that? I can't think about an easy algorithm or even about
the structures I should use?

Thx
 
M

Moshazu

Here is one way to achieve this, but maybe not the most efficient. I am
not completely familar with how binding to datatables effects how the
data is added to controls.

Set up two arrayLists, one for the recent selections and one for all
available selections. Fill the all available selections with the data
from the datatable and fill the recent selections with just that. The
next time you need to populate the comboBox, add the recent selected
items first, then add a line, then add all available items.

As long as you don't destroy the recent selections arrayList, you can
just update it accordingly.

Hope this helps...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top