473,763 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exchanging values of properties between two components at design time

Dear Experts,
I have to write a C# program with the following requirements. I
have to make two components (call C1 and C2) both of which can be
included by an end user into his project. I have not decided what they
have to be - an ActiveX component or a class library. Each of these
objects has a set of properties. End users will create forms that
contain these components. Now there is a requirement that the value of
one of the properties of component C1 has to be available to C2 at
"design time". The idea is that the end user needs to set the value of
some common properties in only one of the components and the other
components automatically "get" this value. This saves typing time for
the user and prevents users from typing different values for different
components (which is not allowed in our application). Is this possible?
If yes, how? Thanks.

Regards,
Ganesh Okade

Aug 11 '06 #1
5 1611
"ga*********@gm ail.com" wrote:
I have to write a C# program with the following requirements. I
have to make two components (call C1 and C2) both of which can be
included by an end user into his project...
Now there is a requirement that the value of
one of the properties of component C1 has to be available to C2 at
"design time". The idea is that the end user needs to set the value of
some common properties in only one of the components and the other
components automatically "get" this value. This saves typing time for
the user and prevents users from typing different values for different
components (which is not allowed in our application). Is this possible?
Yes, but it's not trivial. To have one component update the properties of
another component at design time, you need to create a custom
ComponentDesign er for your components. Then you need to provide the
IComponentChang eService interface in your ComponentDesign er so that you can
monitor for the ComponentChange d event raised by your other component.

The book "Pro .NET 2.0 Windows Forms and Custom Controls in C#" (Matthew
MacDonald, APress 2006) is an excellent book that details how to do this.

Another possibility is to provide some sort of interprocess communications
between the two components to keep each other in sync. We offer a .NET
component FREE for non-commercial use that provides fast & efficient IPC:

http://www.mini-tools.com/goto/comm

--
Timm Martin
Mini-Tools
..NET Components and Windows Software
http://www.mini-tools.com

Aug 11 '06 #2
I believe the easiest solution is to use delegate. Delclare a delegate in C1 and register it in C2. When you want C2 to be notified with changes are made in C1, simply raise it through C1 and pass the values that C2 needs to be notified as Delegate argument.
Hope this would solve your problem.
Sheraz.
---
Posted via www.DotNetSlackers.com
Aug 11 '06 #3
Dear Timm/Sheraz,
Thank you for your responses.

I have one question regarding the responses from both of you. You
solutions look like they require the component to be "running" for them
to work. At design time will the components really "run"?

Regards,
Ganesh

Sheraz wrote:
I believe the easiest solution is to use delegate. Delclare a delegate in C1 and register it in C2. When you want C2 to be notified with changes are made in C1, simply raise it through C1 and pass the values that C2 needs to be notified as Delegate argument.
Hope this would solve your problem.
Sheraz.
---
Posted via www.DotNetSlackers.com
Aug 14 '06 #4
"ga*********@gm ail.com" wrote:
Dear Timm/Sheraz,
Thank you for your responses.
I have one question regarding the responses from both of you. You
solutions look like they require the component to be "running" for them
to work. At design time will the components really "run"?
Yes, that is the "magic" of .NET design time, that your controls and
components are actually running inside the design environment. In some cases
you may not want your component to initialize or execute some aspect during
design time, in which case you may need to perform the following check:

if (this.DesignMod e)
// do something only at run-time

--
Timm Martin
Mini-Tools
..NET Components and Windows Software
http://www.mini-tools.com

Aug 14 '06 #5
Hi Timm,
Thanks again for taking time to respond. That's something great
about .NET! Thanks - I guess that resolves my problem.

Regards,
Ganesh Okade

Mini-Tools Timm wrote:
"ga*********@gm ail.com" wrote:
Dear Timm/Sheraz,
Thank you for your responses.
I have one question regarding the responses from both of you. You
solutions look like they require the component to be "running" for them
to work. At design time will the components really "run"?

Yes, that is the "magic" of .NET design time, that your controls and
components are actually running inside the design environment. In some cases
you may not want your component to initialize or execute some aspect during
design time, in which case you may need to perform the following check:

if (this.DesignMod e)
// do something only at run-time

--
Timm Martin
Mini-Tools
.NET Components and Windows Software
http://www.mini-tools.com
Aug 15 '06 #6

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

Similar topics

0
1280
by: Peter Morris | last post by:
Hi all I want to create a new component which will be a singleton. I then also need some way to have the .NET designers to allow me to link properties of components on other forms to the components owned by the singleton. It is essential that I can do this at design-time using the property grids. Any suggestions as to an approach I might investigate? --
4
9782
by: james | last post by:
I have a custom UserControl, which can have many sub class levels derived from it. I want to be able to discover all the components at Load time, but the only components I can see from the base class are the private components internal to the base class itself. What I want are ALL components for the entire class no matter how many levels of sub-classing this particular control contains. I do not want to have to force the child classes to...
5
2756
by: Guy | last post by:
Guys Hope someone can help me! I'm having real problems getting properties I type against a control I have written at design time I have written a control by inheriting from the Button control. I am trying to add a feature whereby the control changes to a different color when the mouse floats over it, or when the button has the focus. The color changing works if the 'LightColor' is set at runtime in code. However, if I draw the control on...
26
1763
by: julien | last post by:
Hello, I don't know when to use fields and when to used properties. It looks to me that using properties is always better. But I guess fields must be better in some cases, otherwise they wouldn't exist! Thank you Julien
0
1092
by: Kat | last post by:
Hi I'm making a component in C# (Visual Studio 2003) that is a 2D game board. The board is supported by a 2D array of objects. At design time, the programmer can place the objects onto the board. However, when you run the program containing the component, all the design time changes are lost. It appears that the properties (like the array of objects) is not persistent between design time and run time. I have tried serializing the...
1
953
by: Sajid | last post by:
Hello!!! I have a form called "Main", which has a datagrid. Now what I want to do is to allow a user to select anyone of the rows on the datagrid (on the "Main" form) and then click a button to get another form which has a listbox with list of values. When a user clicks on anyone of the values from the listbox that must be copied back to the selected Row on the DataGrid (on the "Main" form). How can I do that. Your kind help will be...
3
5015
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change data in the text boxes. Then an "update" button saves the data back to the database. What is the best way to change several properties on most of the textbox controls on the form when the "modify" button is clicked? (e.g. make them editible (and...
4
2142
by: Charlie | last post by:
I am trying to create dynamic content in a Windows Form using external data to determine UI elements. The code works fine at runtime. I have tried adding code in Sub New, after InitializeComponent. InitializeComponent apparently runs at design time as the design time view of the Form is created, but the code after the call to InitializeComponent appears not to run. Is there a way to get programmer written code (not created by the...
9
2418
by: Mario Vázquez | last post by:
Hi, I have a component which exposes an extended property. I want to edit this property using a UITypeEditor. The problem is that when the designer raises my UITypeEditor sends a reference of the component it's being edited (a TextBox for example) but not of my component. How can I receive a reference of the component that owns the extended property? Thanks a lot,
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10145
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
9998
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
9938
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
9822
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
5270
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...
1
3917
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
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.