Class controling form settings

  • Thread starter Thread starter Matthew
  • Start date Start date
M

Matthew

I am wondering if it is possible to make something like the following work:

Public Class myTestSettings
Public Property onTop() As Boolean
Get
Return Form1.CheckBox1.Checked
End Get
Set(ByVal Value As Boolean)
Form1.CheckBox1.Checked = Value
End Set
End Property
End Class

Second question: if it is possible, is it advisable?

I am wanting to serialize this information to an XML file. I'm exploring
this as a possibly better way to accomplish this.

Thanks in advance,

Matthew
 
Matthew,

In my opinion it makes no sense at all and makes your program only more
unreadable.
It is an extention to set the checkbox1 or form 1 in a hidden way while you
only want to set the setting in a config (XML) file (although for this kinds
of often done things I would normaly choose the registry when it has to be
saved).

The registry for computer dependend savings of settings.
The config for general saving of settings.
(As well when you have a situation where the user is using 2 or more
computers, however than it is directly not more computer dependend)

Just my thought,

Cor
 
Matthew said:
I am wondering if it is possible to make something like the following work:
<snipped for brievity>

Yes, it is possible.
Second question: if it is possible, is it advisable?

I'd sugggest it is not advisable. If you need a property to indicate what
the state of a control is, then you should make it a property of the form
the control is on, rather than calling into the form from some other module.

The main reason is to maintain encapsulation. Outside code could care
less what the name of the control is, the name is only relavent to the form
it is on. What they do care about is the user's selection for that option.
You can expose the state (value) without having to expose the control.

LFS
 
Cor,

Thanks for your response.

Perhaps it would help if I explained a bit more. In this application, the
user is allowed to save the program state in an XML file. Then, they change
several settings. Then, they save that program state in a different XML
file.
At any time they can restore the program to a previous state. This is a
critical part of my program.

This situation seems to lend itself to separate config files rather than the
registry.
Does this sound true to you too?

Matthew
 
Matthew,

I understand now, what you are up to.

In my opinion can a dataset probably do a good job in that.

Easy to handle and easy to write as XML file.
You can than choose between different rows for the state (and even when you
make a centralized one, for each user a table).

Only you should not set it in the way you do, although it looks almost the
same, something as this however see it as pseudo

\\\
Public Class myTestSettings
private mydatarowitem as boolean =
ds.tables(thisuser).rows(last).("mycheckboxpropertyOnTop")
Public Property onTop() As Boolean
Get
Return mydatarowitem
End Get
Set(ByVal Value As Boolean)
mydatarowitem = Value
End Set
End Property
End Class
////
Use
Form1.CheckBox1.Checked = mytestS.OnTop
mytest.Ontop = .........................

Because that I have to go fast typed here just to give you an idea and not
really complete.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top