473,657 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PropertyBag in VB.NET?

Hello everybody,

I am trying to re-write a VB5-ActiveX-control in VB.NET. I googled for
"PropertyBa g in VB.NET" and found that the only way is serialization
(and writing the properties into a file). Now I wonder...

a) Do I have to include this file with my application?

b) If I use one control in various applications at the same time do
they overwrite that file if the file name is identical?

Thanks for your help!

Best Regards,

HKSHK

Feb 3 '06 #1
3 6026
Hi there,
a) Do I have to include this file with my application?
That's all down to you and how your saving your properties. If your
just saving the last users settings then no, you can create it on the fly if
it doesn't exist, which is always the correct procedure to prevent any
filenotfound exceptions.

If the file contains vast ammounts of complex information that you don't
want to have to create via code then simple store it in the application ass
a resource and if a settings file doesn't exist, dump it.
b) If I use one control in various applications at the same time do
they overwrite that file if the file name is identical?


Are you referring to saving the properties of a control during
design-time? If so don't worry, this is all handled for you automatically
within the forms automatically generated designer code.

If you want to save per/user application settings then you might want to
look into creating simple XML documents to persist your settings. I have an
old example here...

http://www.npsoftware.co.uk/Tutorial...stence_XML.php

I hope this helps.

Nick.
Feb 3 '06 #2
Hi Nick,

Thanks for your reply. It helped a lot.

Now, there's just one more thing I wonder:
I know when I have to read the properties (from the settings file), but
how can I find out if the user changed a property at design time and
save the changes to the file? I want to avoid that the properties are
saved if they are made by code at run-time, but they should be saved if
they are made at design time.

Thanks in advance for your help!

Best Regards,

HKSHK

Feb 6 '06 #3
Hi there,
Now, there's just one more thing I wonder:
I know when I have to read the properties (from the settings file), but
how can I find out if the user changed a property at design time and
save the changes to the file? I want to avoid that the properties are
saved if they are made by code at run-time, but they should be saved if
they are made at design time.


Well this is done automatically for you, the properties that are
modified by the user are stored in the automatically generated code section,
which is hidden in 2005 (not quite sure where it is now).

One way of testing for a property change would be to add code to the Set
part of the property accessor. Check the value coming in and see if it
..Equals the current value, if not then set it and you now know that a change
was made, you could then save the properties to a file. I'm not sure what
kind of performance hit this might give the idea if you have allot of
properties in the control.

As for checking to see if you are in design-time or run-time I am unsure
of this. And unfortuantely do not have enough time to look into it right
now. AFAIK you need to be looking for the Context which the application is
running in. Anyway, I hope this helps.

Nick.
Feb 6 '06 #4

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

Similar topics

8
4558
by: iyuen | last post by:
I'm having problems with converting a byte array to an image object~ My byte array is an picture in VB6 StdPicture format. I've used propertybag to convert the picture into base64Array format in XML, and embedded the array as some child element in an xml file, i.e.: <Mask>bHQAAH4AAABCTX4AAAAAAAAAPgAAACgAAAAQAAAAEAAAAAEAAQAAAAAAQAAAAAAAAAAAAA AA AAAAAAAAAAAAAAAA////AP//AAD//wAA//8AAP//AAD/7wAA//cAALtzAABVeQAAVUAAAFVA...
0
3666
by: Som sally | last post by:
Hi I'm writing a windows user control in C# and 'm not able to retain the change made to the usercontrol public properties. If i drop the user control in the designer, change it's property values and run the program the properties are reverting to the default values. In VB6 there was a convenient way of storing values in PropertyBag collection and accessing via ReadProperties or WriteProperties.
16
5711
by: Larry Woods | last post by:
I need to persist user selections. I know that I can use the Registry, but I was hoping that there was some sort of "text based" solution. TIA, Larry Woods
0
2116
by: Oculus | last post by:
Hi all, I'm in the process of porting an old VB6 app to C# and this app used the PropertyBag to persist some of it's information into a database. They have a considerable amount data that I need to continue using with the new app. I don't need to persist it in the same way, but I do need to be able to load this data. I've been searching the net for any information on how to do this and found nothing. Any help in pointing me in the...
6
2288
by: Galen Somerville | last post by:
My vb6 user control used a propertybag. A typical form would use 6 of these user controls. The setting of one never affected the others. Now I'm supposed to use serialization to replace the property bag. But, the examples I have show saving and retrieving from a file. Since the file is explicitly named, in the samples, how do I keep the instances separate?? GalenS
5
1935
by: Feniks | last post by:
Hello, I have some problems with smart pointers. I want to have smart pointer, copy_ptr in this case in my class like this: class Entity { protected: ..... copy_ptr<PropertyBagmProperties; // <- PropertyBag is a class here
0
1446
by: antonmaju | last post by:
Hi, I have a problem with loading .rpt in my ASP.NET application. I'm using .Crystal Reports Server XI as my report repository. My development machine is using Windows XP SP2 and the production server is using Windows Server 2003. My application works fine in development machine but I got "Database logon failed" message in production server. I have set database login & access rights, web.config and data source location in my .rpt to match the...
0
8421
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
8844
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
8621
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
7354
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
6177
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
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.