Remebering dropdown box values

eramgarden

Contributor
Joined
Mar 8, 2004
Messages
579
I have a dropdown box on a form where I can type in values into the box...

So far so good..

My manager wants functionality that the combobox remembers what the user entered ..so nexttime when they use the app, it shows what they had entered previously... We dont want to save the entries in database...

This is something like ASP.Net and using cookies..

He said there's a class that does that but i cant find any examples..

anyone?
 
I'll look into that but I dont think this is what he's looking for...

He said there's a class for it that remembers the selection..

yes, no?
 
The class you want is System.Net.Cookie but again this is for ASP as the help says "The Cookie class is used by a client application to retrieve information about cookies received with HTTP responses. The following cookie formats are supported during parsing the HTTP resonse headers: Netscape, RFC 2109, and RFC 2965."

Stop trying to do ASP stuff in windows apps, windows allows you to do things easier than asp..
 
one more question:

My manager also wants the "most recently" values under "File" menu..just like , for example, Excel..where under "File"..it remembers the docs recently opened by the user...

is that also done thru XML?
 
To implement a MRU list in a menu, you will need to do the following:

Decide on how to 'save' the information (XML file, registry entry). Personally, this is a good choice for a registry entry - this is how the Office suite actually store this information - check in regedit under:

HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Common\Open Find\Microsoft Excel\Settings\Open\File Name MRU

or

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU


Then, in your applications 'Open' routine, simply add the last opened file to your internal MRU list, and save that list.

Whenever populating the menu, dynamically read from this list and create menu items.

There is no 'automatic' method of doing this - it is up to the end user to write the code to do so. It is not particularly tricky at all.

B
 
Be carefull that the end users security/spyware setup will allow you to modify the register. Isin't the registry being doneaway with in the next version of office.

Either way you need to do some coding, nothing fancy comes cheap...
 
Once, I did a program with several ComboBoxes which would memorize all unique typed phrases into the Access DataBase. Everytime the program would be executed I just would tell it to reload all entryes into the corresponding ComboBoxes. No registry needed here.

I used an Access Database to do this because the program used one, so, why not also use it to perform the memorizing thing?

If the program would not be based on an database I would definitely use an string array to memorize the items, like this:

Code:
// in declares
public string[,] sObjectHistory = new string[x, y];

// x = number of objects plus one
// y = number of historic items I would think it would be need it plus one
The plus means I would add one more to memorize the most recent item used:

Code:
sObjectHistory[x,0] = combobox1.SelecteedIndex

And I also would memorize all items with a loop throught all the targets object items into to the stringArray.

Then I would only need to save it to a file (I love binary format) and reload it everytime the program would start :)

PS: Like previous users said, you will have to code to acomplish this :)

PS2: I said 8 times the word "would" in this post :D
 
Last edited:
Back
Top