954,206 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

combobox - remember last selection

My options in my combobox are added from my mdb database... what I need is for each time my form, or program for that matter loads is to have the selected option default to the option that was last selected. So essentially, I need my combo box to "remember" which record was the last one selected by the user. Can this be done, seems like it should be simple but I haven't been able to find the answer.

ezbie
Newbie Poster
2 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 
My options in my combobox are added from my mdb database... what I need is for each time my form, or program for that matter loads is to have the selected option default to the option that was last selected. So essentially, I need my combo box to "remember" which record was the last one selected by the user. Can this be done, seems like it should be simple but I haven't been able to find the answer.



Hi
I have used vb.net2002 to solve ur problem I hope it will work.
I have used button to show previous selection u may use another thing according to you. The coding is followingDim Previous As Integer = 0
Dim Current As Integer = 0
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Previous = Current
Current = ComboBox1.SelectedIndex
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(ComboBox1.Items(Previous))
End Sub

Ravi Singhal
Newbie Poster
16 posts since Apr 2007
Reputation Points: 12
Solved Threads: 0
 

It's pretty obvious, write the last value to a text file, then read that value from the text file every time you start the program.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You