PC Review


Reply
Thread Tools Rate Thread

Class controling form settings

 
 
Matthew
Guest
Posts: n/a
 
      12th Nov 2004
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


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      13th Nov 2004
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" <(E-Mail Removed)>

>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
>



 
Reply With Quote
 
Larry Serflaten
Guest
Posts: n/a
 
      13th Nov 2004

"Matthew" <(E-Mail Removed)> wrote
> 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
 
Reply With Quote
 
Matthew
Guest
Posts: n/a
 
      14th Nov 2004
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


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      14th Nov 2004
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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ribbon: Controling Which Tab Shows With Each Form Tom Microsoft Access Form Coding 1 30th Jan 2008 08:49 AM
Controling form loads and redrawing =?Utf-8?B?TWljaGFlbCBELiBSZWVk?= Microsoft Dot NET Framework Forms 1 19th Oct 2006 07:47 AM
Controling navagation of a form =?Utf-8?B?QW1hbmRh?= Microsoft Excel Misc 1 28th Apr 2005 07:51 PM
Controling Your Customized Form? Can I minimize it? Mcasteel Microsoft Excel Programming 0 18th Nov 2004 02:51 PM
controling UI of a class Aung Microsoft C# .NET 2 23rd Nov 2003 04:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:16 AM.