Hi,

Am using VB.NET.
I have a search page in one form(Search.vb) and another form(Form1.vb) to display the details of selected data from the search form.

I already have back button in Form1.vb which returns to some other form say (Action.vb).

In case of searching data it returns to Form1 to modify the selected data, In this case if i press the back button in Form1.vb it should return to search.vb with the details that i entered for searching.

How can i do this in VB.NET?
Is there any way to save and restore the form whenever needed with its details?

Thanks :-)

Recommended Answers

All 13 Replies

You could always save each field by using

SaveSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", textbox1.txt) 
' Do a version of the line above for each field you want to save

Then when you reload the form put the following in the load event

Textbox1.text = GetSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", "(default)")

Hi,

Exactly in which part of the code i have to use the above line

SaveSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", textbox1.txt)

And

Textbox1.text = GetSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", "(default)")

Hi,

Exactly in which part of the code i have to use the above line

SaveSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", textbox1.txt)

And

Textbox1.text = GetSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", "(default)")

as the_carpenter already mentioned ...
the Form/application load event you call the method (which you have of course fill with your requirements) to get your settings.

Saving the settings most likely should happen either on application shutdown OR when the user presses the "save settings" button (which you also have of course to code)

I think adding savesetting to form.close application event will do the job.
As you already know add get setting to form load event.

my bad. you have to use the following

Private Sub form_Closing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
     SaveSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", textbox1.txt) 
End Sub

Private Sub form_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
     Textbox1.text = GetSetting(My.Application.Info.Title.ToString, "SearchForm", "Textbox1", "(default)")
End Sub

Thank u carpenter,

It works fine..

Hi,

In case of restoring textbox value it works fine.

What about restoring the gridview values in VB.NET???

gridview?

Are you not connecting that to a data source anyway?

But if you did want to save every setting of a grid view... you would need to manually go through and save each settinng with a new line of savesetting.

Yes, DataGridview gets loaded from access database.

I have to loop through each and every row and use savesetting?

Yes datagridview gets loaded from MS Access database.

Well, if it's connected to a database what would you need to save? Is the data saved in the database?

Yeah.. its connected to database and displays the data based on some search criteria.

While leaving that page grid view should save that data, and again while am coming back to that page i need to get the data in gridview as default view.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.