944,172 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 3312
  • VB.NET RSS
Apr 17th, 2007
0

combobox - remember last selection

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ezbie is offline Offline
2 posts
since Apr 2007
Apr 20th, 2007
0

Re: combobox - remember last selection

Click to Expand / Collapse  Quote originally posted by ezbie ...
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 following

Dim 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
Reputation Points: 12
Solved Threads: 0
Newbie Poster
Ravi Singhal is offline Offline
16 posts
since Apr 2007
Apr 21st, 2007
0

Re: combobox - remember last selection

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.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: adding controls dynamically
Next Thread in VB.NET Forum Timeline: WSDL file EDITING





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC