Author Topic: retentive data on AHMI restart  (Read 2161 times)

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
retentive data on AHMI restart
« on: December 31, 2014, 11:56:52 AM »
Im using VS2013 for AHMI. Im wondering is there a way to have retentive data when AHMI restarts. For instance if I enter a value into textbox1 then restart AHMI will the previous value still be there?  I would not want to re-enter all my data upon restart  Is this possible, thanks. 

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: retentive data on AHMI restart
« Reply #1 on: December 31, 2014, 12:26:29 PM »
Each control has a Property named (ApplicationSettings). You can use this to bind properties to a Setting. The settings are saved on a proper exit and restored at startup.

If you right click your project and select properties, then select the Settings tab, these are where the settings are stored. It is basically a retentative variable that can be linked to object properties usingthe Application Settings for each control.

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: retentive data on AHMI restart
« Reply #2 on: December 31, 2014, 01:35:04 PM »
ok I see where i can type in a value into the "VALUE" field and this works when i restart AHMI.  i would like to write a new value to this field when I enter a new value in the textbox and press update.  Is this possible, can you show me the code, thanks.   

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: retentive data on AHMI restart
« Reply #3 on: January 02, 2015, 09:37:34 PM »
I did a work around by writing/reading to a .txt file.  seems to work fine.  thanks

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: retentive data on AHMI restart
« Reply #4 on: January 03, 2015, 08:28:24 AM »
So here is how to do it with application settings:

1) Add a TextBox to your form
2) In the Properties window, expand down ApplicationSettings
3) Click in the area of (PropertyBinding) to get the ellipses (3 dots), then click on that to open a dialog window
4) In that dialog window, scroll down to the Text property
5) Click the drop-down for Text and select New, then another dialog window will pop up
6) In the Name property of that dialog window, put any name you wish to call it (referred to as the setting name)
7) Click OK to the 2 dialog windows
8) Run the application
9) Type something in the TextBox
10) Close the application
11) Run the application again
12) You should see the value you put in the TextBox still there

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: retentive data on AHMI restart
« Reply #5 on: January 04, 2015, 03:37:11 PM »
what if a user wanted to change this textbox value by typing a new value then click a button to save it?  Is there a way to write it to that text binding on say Button_click?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: retentive data on AHMI restart
« Reply #6 on: January 04, 2015, 05:22:34 PM »
In the click event handler:

My.Settings.Save