Dynamic UserScopedSettings

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to dynamically create user scoped settings? For example, a
lookup window inside an MDI application that is called by multiple forms and
needs to maintain it's size and position based on the MDI child form from
which it was called.
 
Hi lloyduh234,

Thanks for your post.

Do you use .Net1.1 or .Net2.0? In .Net2.0, winform provided user scoped and
application scoped setting configuration file. For more information, please
refer to the link below:
http://msdn2.microsoft.com/en-us/library/c9db58th.aspx

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Thanks.
I'm using .Net 2.0 (c#). I realize there exists user scoped setting
configuration files. All the examples that I see show a somewhat static
wrapper class. I'm wondering if there are any examples of dynamic creation.
For example, I have a lookup window that needs to save it's position, size,
and grid column widths. The lookup window is called from multiple forms, and
presents different data for each form. I'd like to be able to persist
settings based on who called the lookup form.
 
Hi lloyduh234,

Thanks for your feedback.

I am not sure if I understand your scenario completely. It seems that you
want to persist the setting based on different form not based on the
different windows account, yes?

This requirement is somewhat like the Session concept in Asp.net. However,
there is no any build-in support for this in .Net winform.

If you want to do this, you have to implement some customized code to store
different settings. We should maintain some identification information in
the calling form, so that the lookup window can query to distinguish these
the callers. For example, we can use certain constructor of lookup window
to pass in certain identification information, then we can create a config
file based on different identification passed in.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Thanks.
What I tried was modifying the FormSettings example under the MSDN
ApplicationSettingsBaseClass example. In the constructor, I passed a string
that identifies the form name (_formName).
I then did the following:

[UserScopedSetting()]
[DefaultSettingValueAttribute("0, 0")'
public point FormLocation
{
get { return (Point)(this[_formName + "Location"]); }
set { this[_formName + "Location"] = value; }
}

This way, I could use one wrapper class across my entire application, and
just identify the settings by the calling form.

Should this have worked?

Thanks!
 
Hi lloyduh234,

Yes, this should work. By doing this, each calling form will have an entry
in the user.config file, and whenever you access it, the corresponding
entry will return for the caller(since you have passed the correct calling
form name in the constructor)

If you still have anything unclear, please feel free to let me know. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Just curious if this worked for you? I'm trying to do a similar thing, but
cant get it happening.

lloyduh234 said:
Thanks.
What I tried was modifying the FormSettings example under the MSDN
ApplicationSettingsBaseClass example. In the constructor, I passed a string
that identifies the form name (_formName).
I then did the following:

[UserScopedSetting()]
[DefaultSettingValueAttribute("0, 0")'
public point FormLocation
{
get { return (Point)(this[_formName + "Location"]); }
set { this[_formName + "Location"] = value; }
}

This way, I could use one wrapper class across my entire application, and
just identify the settings by the calling form.

Should this have worked?

Thanks!





"Jeffrey Tan[MSFT]" said:
Hi lloyduh234,

Thanks for your feedback.

I am not sure if I understand your scenario completely. It seems that you
want to persist the setting based on different form not based on the
different windows account, yes?

This requirement is somewhat like the Session concept in Asp.net. However,
there is no any build-in support for this in .Net winform.

If you want to do this, you have to implement some customized code to store
different settings. We should maintain some identification information in
the calling form, so that the lookup window can query to distinguish these
the callers. For example, we can use certain constructor of lookup window
to pass in certain identification information, then we can create a config
file based on different identification passed in.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top