473,765 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to reset Windows Application's default programmaticall y?

Hi Everyone,

I have made a windows application using vb.net 2003. When user opens this
application it will display a default location in a textbox. This
application has to allow user to change the default location and set their
desired location as application’s new default. For instance, if the
application’s default location is Chicago, every time user launches this
program Chicago will be displayed in the textbox. If user changes the
default location to Toronto, then click a button to set Toronto as default.
Later when user opens this application again, it should display Toronto
instead of Chicago. How can I achieve this? Please help.

Thank you in advance.

Nina
Sep 20 '06 #1
6 4436
Hey Nina,
You might want to use windows registry to do this.
Use SaveSetting() to store the setting into registry and GetSetting to
retreive it back.

Use SaveSetting("Ap plicationName", "FolderName ", "City", "Chicago") to
store after user selects a different city.

Use txtboxCityName. text = GetSetting("App licationName", "FolderName ",
"City", "DefaultVal ue") when you load the form to fill up the textbox

Hope it helps.

Sep 20 '06 #2
Another option is to use XML files. Check out the XML document object
model. Be warned that this approach is more difficult to set up and
requires more code to use. Just throwing in my 2 cents :-)

Thanks,

Seth Rowe

IdleBrain wrote:
Hey Nina,
You might want to use windows registry to do this.
Use SaveSetting() to store the setting into registry and GetSetting to
retreive it back.

Use SaveSetting("Ap plicationName", "FolderName ", "City", "Chicago") to
store after user selects a different city.

Use txtboxCityName. text = GetSetting("App licationName", "FolderName ",
"City", "DefaultVal ue") when you load the form to fill up the textbox

Hope it helps.
Sep 20 '06 #3
I agree with rowe_newsgroups , XML is how I would do it.

Using XML isn't hard either. I use the code below to do exactly this.

Private Sub LoadSettings()

Dim dsSettings as new Dataset
Dim dtSettings as Datatable
Dim SettingsPath As String = Application.Sta rtupPath & "\" &
My.Settings.Ser verSettingsFile

dsSettings.Data SetName = "ServerSettings "

If IO.File.Exists( SettingsPath) Then
dsSettings.Read Xml(SettingsPat h)
dtSettings = dsSettings.Tabl es("HardDriveSe ttings")

Else

Dim dcSN As New DataColumn 'Server Name
Dim dcDTM As New DataColumn 'Drive to monitor.
Dim dcFSTH As New DataColumn 'Free Space Threshhold in GBs
Dim drSettings As DataRow

dcSN.ColumnName = "ServerName "
dcSN.DataType = GetType(System. String)
dcDTM.ColumnNam e = "DriveLeter "
dcDTM.DataType = GetType(System. String)
dcFSTH.ColumnNa me = "FreeSpaceThres hHold"
dcFSTH.DataType = GetType(System. Int32)

dtSettings = New DataTable
dtSettings.Tabl eName = "HardDriveSetti ngs"

dtSettings.Colu mns.Add(dcSN)
dtSettings.Colu mns.Add(dcDTM)
dtSettings.Colu mns.Add(dcFSTH)

drSettings = dtSettings.NewR ow
drSettings(0) = "stc-dc"
drSettings(1) = "D:"
drSettings(2) = 15
dtSettings.Rows .Add(drSettings )

End If

End Sub

In the above example I created a settings file for a program which
monitors hard drive space on production servers. Using XML to store the
list of servers to be monitored along with the dirve letter and free
space setting.

In your case after you load the settings using dsSettings.Read Xml(Path)
and after your users make a change you would then call
dsSettings.Writ eXml(Path) to write the change to disk.

Izzy

rowe_newsgroups wrote:
Another option is to use XML files. Check out the XML document object
model. Be warned that this approach is more difficult to set up and
requires more code to use. Just throwing in my 2 cents :-)

Thanks,

Seth Rowe

IdleBrain wrote:
Hey Nina,
You might want to use windows registry to do this.
Use SaveSetting() to store the setting into registry and GetSetting to
retreive it back.

Use SaveSetting("Ap plicationName", "FolderName ", "City", "Chicago") to
store after user selects a different city.

Use txtboxCityName. text = GetSetting("App licationName", "FolderName ",
"City", "DefaultVal ue") when you load the form to fill up the textbox

Hope it helps.
Sep 20 '06 #4
I agree with rowe_newsgroups , XML is how I would do it.

Using XML isn't hard either. I use the code below to do exactly this.

Private Sub LoadSettings()

Dim dsSettings as new Dataset
Dim dtSettings as Datatable
Dim SettingsPath As String = Application.Sta rtupPath & "\" &
My.Settings.Ser verSettingsFile

dsSettings.Data SetName = "ServerSettings "

If IO.File.Exists( SettingsPath) Then
dsSettings.Read Xml(SettingsPat h)
dtSettings = dsSettings.Tabl es("HardDriveSe ttings")

Else

Dim dcSN As New DataColumn 'Server Name
Dim dcDTM As New DataColumn 'Drive to monitor.
Dim dcFSTH As New DataColumn 'Free Space Threshhold in GBs
Dim drSettings As DataRow

dcSN.ColumnName = "ServerName "
dcSN.DataType = GetType(System. String)
dcDTM.ColumnNam e = "DriveLeter "
dcDTM.DataType = GetType(System. String)
dcFSTH.ColumnNa me = "FreeSpaceThres hHold"
dcFSTH.DataType = GetType(System. Int32)

dtSettings = New DataTable
dtSettings.Tabl eName = "HardDriveSetti ngs"

dtSettings.Colu mns.Add(dcSN)
dtSettings.Colu mns.Add(dcDTM)
dtSettings.Colu mns.Add(dcFSTH)

drSettings = dtSettings.NewR ow
drSettings(0) = "stc-dc"
drSettings(1) = "D:"
drSettings(2) = 15
dtSettings.Rows .Add(drSettings )

End If

End Sub

In the above example I created a settings file for a program which
monitors hard drive space on production servers. Using XML to store the
list of servers to be monitored along with the dirve letter and free
space setting.

In your case after you load the settings using dsSettings.Read Xml(Path)
and after your users make a change you would then call
dsSettings.Writ eXml(Path) to write the change to disk.

Izzy

rowe_newsgroups wrote:
Another option is to use XML files. Check out the XML document object
model. Be warned that this approach is more difficult to set up and
requires more code to use. Just throwing in my 2 cents :-)

Thanks,

Seth Rowe

IdleBrain wrote:
Hey Nina,
You might want to use windows registry to do this.
Use SaveSetting() to store the setting into registry and GetSetting to
retreive it back.

Use SaveSetting("Ap plicationName", "FolderName ", "City", "Chicago") to
store after user selects a different city.

Use txtboxCityName. text = GetSetting("App licationName", "FolderName ",
"City", "DefaultVal ue") when you load the form to fill up the textbox

Hope it helps.
Sep 20 '06 #5
Thank you IdleBrain, rowe_newsgroups , and Izzy for all your help. Now I know
where to start. Have a nice day!

Nina

"Izzy" wrote:
I agree with rowe_newsgroups , XML is how I would do it.

Using XML isn't hard either. I use the code below to do exactly this.

Private Sub LoadSettings()

Dim dsSettings as new Dataset
Dim dtSettings as Datatable
Dim SettingsPath As String = Application.Sta rtupPath & "\" &
My.Settings.Ser verSettingsFile

dsSettings.Data SetName = "ServerSettings "

If IO.File.Exists( SettingsPath) Then
dsSettings.Read Xml(SettingsPat h)
dtSettings = dsSettings.Tabl es("HardDriveSe ttings")

Else

Dim dcSN As New DataColumn 'Server Name
Dim dcDTM As New DataColumn 'Drive to monitor.
Dim dcFSTH As New DataColumn 'Free Space Threshhold in GBs
Dim drSettings As DataRow

dcSN.ColumnName = "ServerName "
dcSN.DataType = GetType(System. String)
dcDTM.ColumnNam e = "DriveLeter "
dcDTM.DataType = GetType(System. String)
dcFSTH.ColumnNa me = "FreeSpaceThres hHold"
dcFSTH.DataType = GetType(System. Int32)

dtSettings = New DataTable
dtSettings.Tabl eName = "HardDriveSetti ngs"

dtSettings.Colu mns.Add(dcSN)
dtSettings.Colu mns.Add(dcDTM)
dtSettings.Colu mns.Add(dcFSTH)

drSettings = dtSettings.NewR ow
drSettings(0) = "stc-dc"
drSettings(1) = "D:"
drSettings(2) = 15
dtSettings.Rows .Add(drSettings )

End If

End Sub

In the above example I created a settings file for a program which
monitors hard drive space on production servers. Using XML to store the
list of servers to be monitored along with the dirve letter and free
space setting.

In your case after you load the settings using dsSettings.Read Xml(Path)
and after your users make a change you would then call
dsSettings.Writ eXml(Path) to write the change to disk.

Izzy

rowe_newsgroups wrote:
Another option is to use XML files. Check out the XML document object
model. Be warned that this approach is more difficult to set up and
requires more code to use. Just throwing in my 2 cents :-)

Thanks,

Seth Rowe

IdleBrain wrote:
Hey Nina,
You might want to use windows registry to do this.
Use SaveSetting() to store the setting into registry and GetSetting to
retreive it back.
>
Use SaveSetting("Ap plicationName", "FolderName ", "City", "Chicago") to
store after user selects a different city.
>
Use txtboxCityName. text = GetSetting("App licationName", "FolderName ",
"City", "DefaultVal ue") when you load the form to fill up the textbox
>
Hope it helps.

Sep 21 '06 #6
Hello Izzy,

I don't like this approach. Datasets dont feel right for storing application
settings. A custom object would be a better approach. It feels better.
It also allows your settings to take advantage of strongly typed data, and
intellisense within the IDE.

-Boo
I agree with rowe_newsgroups , XML is how I would do it.

Using XML isn't hard either. I use the code below to do exactly this.

Private Sub LoadSettings()

Dim dsSettings as new Dataset
Dim dtSettings as Datatable
Dim SettingsPath As String = Application.Sta rtupPath & "\" &
My.Settings.Ser verSettingsFile
dsSettings.Data SetName = "ServerSettings "

If IO.File.Exists( SettingsPath) Then
dsSettings.Read Xml(SettingsPat h)
dtSettings = dsSettings.Tabl es("HardDriveSe ttings")
Else

Dim dcSN As New DataColumn 'Server Name
Dim dcDTM As New DataColumn 'Drive to monitor.
Dim dcFSTH As New DataColumn 'Free Space Threshhold in GBs
Dim drSettings As DataRow
dcSN.ColumnName = "ServerName "
dcSN.DataType = GetType(System. String)
dcDTM.ColumnNam e = "DriveLeter "
dcDTM.DataType = GetType(System. String)
dcFSTH.ColumnNa me = "FreeSpaceThres hHold"
dcFSTH.DataType = GetType(System. Int32)
dtSettings = New DataTable
dtSettings.Tabl eName = "HardDriveSetti ngs"
dtSettings.Colu mns.Add(dcSN)
dtSettings.Colu mns.Add(dcDTM)
dtSettings.Colu mns.Add(dcFSTH)
drSettings = dtSettings.NewR ow
drSettings(0) = "stc-dc"
drSettings(1) = "D:"
drSettings(2) = 15
dtSettings.Rows .Add(drSettings )
End If

End Sub

In the above example I created a settings file for a program which
monitors hard drive space on production servers. Using XML to store
the list of servers to be monitored along with the dirve letter and
free space setting.

In your case after you load the settings using
dsSettings.Read Xml(Path) and after your users make a change you would
then call dsSettings.Writ eXml(Path) to write the change to disk.

Izzy

rowe_newsgroups wrote:
>Another option is to use XML files. Check out the XML document
object model. Be warned that this approach is more difficult to set
up and requires more code to use. Just throwing in my 2 cents :-)

Thanks,

Seth Rowe

IdleBrain wrote:
>>Hey Nina,
You might want to use windows registry to do this.
Use SaveSetting() to store the setting into registry and GetSetting
to
retreive it back.
Use SaveSetting("Ap plicationName", "FolderName ", "City", "Chicago")
to store after user selects a different city.

Use txtboxCityName. text = GetSetting("App licationName",
"FolderName ", "City", "DefaultVal ue") when you load the form to fill
up the textbox

Hope it helps.

Sep 21 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2641
by: Charles M. Fish, Sr. | last post by:
I’m so tired from banging this problem around all day, I hope I can explain it succinctly & accurately. I want to execute a function immediately following a click on <input type="RESET"... The function will insert today’s date into a <input type="TEXT"… field. It does it just fine with <form onload="insertDate();" where inside the ‘insertDate’ fn, I have document.form.dateField.value = dateString. The closest I’ve been able to do...
9
7026
by: Hardy Wang | last post by:
Hi all: I read an article from http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp about how to install a windows service programmatically. Based ont the code sample, it provides the feature to install service under LocalSystem account. What I need is to install service under some other certian account. By further studying the code, and MSDN...
1
2845
by: Silverton Mike | last post by:
I need to retrieve Windows Media Player playlists programmatically via C# from a desktop machine. Does WMP keep track of used/created playlists via registry entries or a saved file on the hard disk? I know WMP likes to save its playlists in directories such as: H:\Documents and Settings\Administrator\My Documents\My Music\My Playlists but any .wpl files saved outside such a scheme wont be found if only looking here.
16
2121
by: Marina | last post by:
Hi, I am trying to find the minimum security settings to allow a windows control embedded in IE have full trust. If I give the entire Intranet zone full trust, this works. However, this is very broad and gives the entire zone high privleges. I tried giving just the assembly full trust (using the full URL for the DLL), but this doesn't seem to work.
2
4840
by: Lance | last post by:
I want to be able to reset a complex property in a PropertyGrid. I know that for properties that are ValueTypes you can include System.ComponentModel.DefaultValue in the declaration of the property. But, for complex property types (e.g., instance types) this does not work because System.ComponentModel.DefaultValue requires a constant value In order to indicate if a property should be serialized you can include a boolean function named...
6
2316
by: PiotrKolodziej | last post by:
Hi When my application is on, i can't reset or power off computer. Every program closes but this one.... Why this happens? PK
16
1844
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. I'm looking for a way to programmatically retrieve the following if possible: Windows Installation Key or COA from the registry Windows installed applications, like: MS Office 97-2003 MS FrontPage MS Word MS Works
8
2316
by: TomC | last post by:
I want to bypass the Windows Form Designer in VS, to create a form programmatically. The elements of the form are to be arranged in a table, and I want the size of the table (and therefore the number of elements) to be determined at runtime, so dragging and dropping on the Form Designer won't cut the mustard. I'm coming from a Java background, and have almost always built my GUI's programmatically, but I realize that in C# this practice...
16
2086
by: Giovanni D'Ascola | last post by:
Hi. I noticed that <input type="reset"actually don't enable checkbutton which are checked by default after they have been disabled by javascript. It's a bug?
0
9566
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10153
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9946
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8830
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7371
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5272
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5413
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.