473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Design time link

Hi,

Is it possible in visual studio 2005 at design time to link
a control on Form 1 to another control on Form 2.

Regards

Charles Mifsud
Shireburn Software Ltd.
Apr 16 '07 #1
7 1491
What do you mean by linking them? You want to access data from a control on
one form by a control on another form? You want to change one control and
have it change the other automically? Can you give more information?

Robin S.
------------------------------------
"supportdev" <su********@newsgroups.nospamwrote in message
news:D9**********************************@microsof t.com...
Hi,

Is it possible in visual studio 2005 at design time to link
a control on Form 1 to another control on Form 2.

Regards

Charles Mifsud
Shireburn Software Ltd.

Apr 16 '07 #2
Hi Robin,

We want to create a control which handles on execute events, text, enabled,
visible and hint properties like actions in Delphi.

Our problem is that we are going to have repetitive actions in different
forms which we want to handle in one central place. We want to have one
central form or one user control with all the actions and their code for the
whole application.

We want to associate these actions with the controls in the different forms.

Regards

Charles Mifsud
Shireburn Software Ltd.
"RobinS" wrote:
What do you mean by linking them? You want to access data from a control on
one form by a control on another form? You want to change one control and
have it change the other automically? Can you give more information?

Robin S.
------------------------------------
"supportdev" <su********@newsgroups.nospamwrote in message
news:D9**********************************@microsof t.com...
Hi,

Is it possible in visual studio 2005 at design time to link
a control on Form 1 to another control on Form 2.

Regards

Charles Mifsud
Shireburn Software Ltd.


Apr 17 '07 #3
Hi Charles,

I am sorry that I couldn't understand your question exactly.

Could you please tell me what you mean by 'link a control on Form1 to
another control on Form2 at design time'?

Only if I understand your question, I could provide you with possible
assistance.

I look forward to your reply.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 17 '07 #4
Hi Charles,

Sorry that I didn't see your latest message when I wrote my first reply.

If you'd like to call a method when you click a button, for instsance, you
could subscribe the Click event of the button and call the method you'd
like in the button's Click event handler.

To subscribe the Click event of a Button, we could double-click the button
on the form in the designer, and the form designer will generate code to
subscribe the Click event automatically as well as the Click event handler
method in the code view.

Alternatively, we could subscribe the Click event by code. The following is
a sample.

VB.NET sample:

AddHandler Button1.Click, AddressOf Button1_Click
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
...
End Sub

C# sample:

this.button1.Click +=new EventHandler(button1_Click);
private void button1_Click(object sender, EventArgs e)
{
......
}

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Apr 17 '07 #5
Hi Linda,

We misunderstood eachother.

We are interested in developing a component for our company where this is
placed on the main form. This control will be controlling the whole
application.

As an example let us say we have 5 forms with a button and a menu.
Form1, Form2, Form3,Form4 and Form5.

We want to create a control like TActionList in Delphi
and create 1 action.

Control.Action1 = ReportName.Preview();

So instead of going in all the forms and writing in the menuitem and the
button click event ReportName.Preview(); we want just to hook this
control.Action1 to all these forms, so when I click the button or menuitem in
any form it would load the report.

So If we have a situation where a user does not have security rights to view
this report in TActionList of Delphi we just write Control.Action1.Enabled =
false; and all the forms will have the Button and MenuItem disabled
automatically.

Thanks again

Charles
--
Regards

Charles Mifsud
Shireburn Software Ltd.
"Linda Liu [MSFT]" wrote:
Hi Charles,

Sorry that I didn't see your latest message when I wrote my first reply.

If you'd like to call a method when you click a button, for instsance, you
could subscribe the Click event of the button and call the method you'd
like in the button's Click event handler.

To subscribe the Click event of a Button, we could double-click the button
on the form in the designer, and the form designer will generate code to
subscribe the Click event automatically as well as the Click event handler
method in the code view.

Alternatively, we could subscribe the Click event by code. The following is
a sample.

VB.NET sample:

AddHandler Button1.Click, AddressOf Button1_Click
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
...
End Sub

C# sample:

this.button1.Click +=new EventHandler(button1_Click);
private void button1_Click(object sender, EventArgs e)
{
......
}

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Apr 19 '07 #6
Hi Charles,

Thank you for your detailed explanation.

NET Windows Forms application programming model doesn't provide such a
control as the TActionList in Delphi. But we could accomplish the similar
function by set the common function as the event handler of all controls
that need to have the same function.

Let's say we have two forms,e.g. Form1 and Form2. Form1 has a Button called
button1 and Form2 has a Button called button2. If we need to call the same
function when we click the button1 on Form1 and click the button2 on Form2,
we could subscribe the Click event of button1 and button2 as follows:

private void Form1_Load(object sender, EventArgs e)
{
this.button1.Click +=new EventHandler(Class1.Method1);
this.button2.Click +=new EventHandler(Class1.Method1);
}
// define the common function in a class
public class Class1
{
public static void Method1(object sender, EventArgs e)
{
MessageBox.Show("calling method1");
}
}

To set the Enabled propery of all the buttons globally as you described, we
could bind the Enabled property of all the buttons to a variable. In this
case, we may add a public property in the above Class1 and bind the public
property to the Enabled property of the buttons. To get the bound buttons
notified when the data source is changed, we need to implement the
INotifyPropertyChanged interface on the Class1.

The following is a sample.

using System.ComponentModel;
class Class1:INotifyPropertyChanged
{
public bool enabled = true;
public bool Enabled
{
get { return enabled; }
set
{
enabled = value;
if (PropertyChanged != null)
PropertyChanged(this, new
PropertyChangedEventArgs("Enabled"));
}
}
public static void Method1(object sender, EventArgs e)
{
MessageBox.Show("calling method1");
}

public event PropertyChangedEventHandler PropertyChanged;

}
private void Form1_Load(object sender, EventArgs e)
{
this.button1.Click +=new EventHandler(Class1.Method1);
this.button2.Click +=new EventHandler(Class1.Method1);

this.button1.DataBindings.Add("Enabled", c, "Enabled");
this.button2.DataBindings.Add("Enabled", c,"Enabled");

}

Then we could set the Enabled property of the object 'c' to false to
disable both of the buttons globally as follows:
c.Enabled = false;

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Apr 20 '07 #7
Hi Charles,

How about the problem now?

If you have any question, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Apr 24 '07 #8

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

Similar topics

33
by: Joe | last post by:
I'm designing a company website. I'm relatively new to CSS and I'm having trouble creating what seems to me a very simple design: - body background: fixed full page image - banner: fixed, 100...
10
by: Matt Fielder | last post by:
I have developed a custom control to be used in my application. My application includes a form designer, so the control can be hosted while designmode for the control is either true or false,...
10
by: BlueDolphin | last post by:
I'm not sure if this is a question or more of a rant... but I'm looking for some input on this from other developers out there. How often has the following happened to you and how have you dealt...
1
by: sylviams | last post by:
I need a database to record students names etc and also to record their levels at six times during the year for a range of subjects. Obviously there can only be one entry per student subject per...
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
1
by: Nogusta123 | last post by:
Hi, I have had a lot of problems getting web pages, master pages and content pages to render in VS2005 design view the same as they would in Internet Explorer. I did a lot of looking on the...
17
by: roN | last post by:
Hi, I'm creating a Website with divs and i do have some troubles, to make it looking the same way in Firefox and IE (tested with IE7). I checked it with the e3c validator and it says: " This...
4
by: Mike | last post by:
I encountered this problem for the first time today while trying to add some columns to a query from a linked DBASEIII file. The new columns that I added on the design grid do not show up on the...
1
by: zawmn83 | last post by:
I want to place a lot of link labels in a group box. At run time, some linklabels are hidden and all other linklabels are need to rearrange. I'm doing it by using the following code For Each...
2
by: Joey | last post by:
I have written an app in C#/asp.net 2.0 that is a system built to handle a large number of scenarios. Part of that system involves allowing users to download large files. As part of my original...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.