Hi all,
I am not sure if this is the right NG to post this question. If
that's the case please point me to the correct NG.
I have a class library(myLib.d ll) which has a class(myClass) which has a
method(myClassM ethod) that creates a form with a button on it. The
application that calls the dll is a windows application(myW inApp).
When in myWinApp I do, myClass.myClass Method, a form is created.
What I would like to know is, how can i access the click event of the form
that has been just created with the above call.
Thanks,
Mounil. 7 1920
What do you mean "access the click event"? Do you mean attach a handler to
it or something?
Well, you might need to change your architecture a little. Maybe the method
should return a reference to the form.
"MounilK" <mo*****@maxit. com.au> wrote in message
news:u0******** ******@TK2MSFTN GP15.phx.gbl... Hi all, I am not sure if this is the right NG to post this question. If that's the case please point me to the correct NG.
I have a class library(myLib.d ll) which has a class(myClass) which has a method(myClassM ethod) that creates a form with a button on it. The application that calls the dll is a windows application(myW inApp).
When in myWinApp I do, myClass.myClass Method, a form is created.
What I would like to know is, how can i access the click event of the form that has been just created with the above call.
Thanks, Mounil.
Hi Peter,
Thanks for replying.Here's my code snippets
in the class library:-
public class MyClass
{
public void MyClassMethod()
{
frmParameterFor m = new System.Windows. Forms.Form();
System.Windows. Forms.Button myButton = new
System.Windows. Forms.Button();
frmParameterFor m.Controls.Add( myButton);
frmParameterFor m.ShowDialog();
}
}
in the windows application WinApp:-
in the form1's button1's click event:
myClass cls = new myClass();
cls.MyClassMeth od();
What I would like to know is how can i now handle the click event of the
form that was created by the cls.MyClassMeth od call?
I am pretty new to this, so please excuse me if i sound naive.
Thanks,
Mounil.
"Peter Rilling" <pe***@nospam.r illing.net> wrote in message
news:eM******** ******@TK2MSFTN GP09.phx.gbl... What do you mean "access the click event"? Do you mean attach a handler to it or something?
Well, you might need to change your architecture a little. Maybe the method should return a reference to the form.
"MounilK" <mo*****@maxit. com.au> wrote in message news:u0******** ******@TK2MSFTN GP15.phx.gbl... Hi all, I am not sure if this is the right NG to post this question. If that's the case please point me to the correct NG.
I have a class library(myLib.d ll) which has a class(myClass) which has a method(myClassM ethod) that creates a form with a button on it. The application that calls the dll is a windows application(myW inApp).
When in myWinApp I do, myClass.myClass Method, a form is created.
What I would like to know is, how can i access the click event of the form that has been just created with the above call.
Thanks, Mounil.
After creating the button in MyClassMethod() constructor, add an
eventhandler to the button:
this.myButton.C lick += new System.EventHan dler(this.myBut ton_Click);
Then, you must define also in your class the myButton_Click event, so
as the eventhandler knows it. Do it this way:
private void myButton_Click( object sender, System.EventArg s e)
{
// put code to execute after myButton is clicked
}
This is the way VS.NET designer also works when you double click a
button in a VS.NET's designer mode.
Why are you using this "strange" approach of building forms through a
separate DLL? Any special requirements?
Hope it helps. Regards.
Well, first, you're going about this all wrong. You have a class that
contains a form. You should create a class that IS a form, that is, inherits
System.Windows. Forms.Form. There is no reason to put the form inside a
class. You're putting a container inside a container. The class that holds
the Windows Form class does nothing. Imagine, for example, that it's
Christmas. Your brother gives you a presnt, a nicely wrapped box. You tear
off the wrapping and open the box. Inside it is another box. You open that
box, and your present is inside it. Why did your brother put the box with
your present in it inside another box?
it sounds to me like you're no well-acquainted with Object-oriented
programming. When you inherit a class, you are creating a new class that has
all the characteristics of the old class, but with additional
characteristics you define. So, you don't put a form inside a class. You
inherit a Form class and write your own implementation of it.
Once you've done that, the Dialog form you've created handles the button's
click event itself. After all, the button is a member of the form. If you
want to do something with the data in the Dialog form in the form that opens
it (by calling the ShowDialog method of the form, rather than having the
form call its own ShowDialog method), you expose that data via a public, or
internal property or method.
If you are serious about using .Net, study up on object-oriented programming
principles, They make .Net powerful, and easy to use, if you employ them
correctly.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.
"MounilK" <mo*****@maxit. com.au> wrote in message
news:O8******** ******@TK2MSFTN GP10.phx.gbl... Hi Peter, Thanks for replying.Here's my code snippets
in the class library:-
public class MyClass { public void MyClassMethod() { frmParameterFor m = new System.Windows. Forms.Form(); System.Windows. Forms.Button myButton = new System.Windows. Forms.Button();
frmParameterFor m.Controls.Add( myButton); frmParameterFor m.ShowDialog(); } }
in the windows application WinApp:-
in the form1's button1's click event:
myClass cls = new myClass(); cls.MyClassMeth od();
What I would like to know is how can i now handle the click event of the form that was created by the cls.MyClassMeth od call? I am pretty new to this, so please excuse me if i sound naive.
Thanks, Mounil.
"Peter Rilling" <pe***@nospam.r illing.net> wrote in message news:eM******** ******@TK2MSFTN GP09.phx.gbl... What do you mean "access the click event"? Do you mean attach a handler to it or something?
Well, you might need to change your architecture a little. Maybe the method should return a reference to the form.
"MounilK" <mo*****@maxit. com.au> wrote in message news:u0******** ******@TK2MSFTN GP15.phx.gbl... Hi all, I am not sure if this is the right NG to post this question. If that's the case please point me to the correct NG.
I have a class library(myLib.d ll) which has a class(myClass) which has a method(myClassM ethod) that creates a form with a button on it. The application that calls the dll is a windows application(myW inApp).
When in myWinApp I do, myClass.myClass Method, a form is created.
What I would like to know is, how can i access the click event of the form that has been just created with the above call.
Thanks, Mounil.
Hi,
You are not hooking the Control.Click event, do that and you will be fine.
Also I recommend you to create your own form with its controls and stuff,
you can visually design it as a regular windows form even if your project is
a dll
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"MounilK" <mo*****@maxit. com.au> wrote in message
news:O8******** ******@TK2MSFTN GP10.phx.gbl... Hi Peter, Thanks for replying.Here's my code snippets
in the class library:-
public class MyClass { public void MyClassMethod() { frmParameterFor m = new System.Windows. Forms.Form(); System.Windows. Forms.Button myButton = new System.Windows. Forms.Button();
frmParameterFor m.Controls.Add( myButton); frmParameterFor m.ShowDialog(); } }
in the windows application WinApp:-
in the form1's button1's click event:
myClass cls = new myClass(); cls.MyClassMeth od();
What I would like to know is how can i now handle the click event of the form that was created by the cls.MyClassMeth od call? I am pretty new to this, so please excuse me if i sound naive.
Thanks, Mounil.
"Peter Rilling" <pe***@nospam.r illing.net> wrote in message news:eM******** ******@TK2MSFTN GP09.phx.gbl... What do you mean "access the click event"? Do you mean attach a handler to it or something?
Well, you might need to change your architecture a little. Maybe the method should return a reference to the form.
"MounilK" <mo*****@maxit. com.au> wrote in message news:u0******** ******@TK2MSFTN GP15.phx.gbl... Hi all, I am not sure if this is the right NG to post this question. If that's the case please point me to the correct NG.
I have a class library(myLib.d ll) which has a class(myClass) which has a method(myClassM ethod) that creates a form with a button on it. The application that calls the dll is a windows application(myW inApp).
When in myWinApp I do, myClass.myClass Method, a form is created.
What I would like to know is, how can i access the click event of the form that has been just created with the above call.
Thanks, Mounil.
Hi,
No really, it's valid that a class contains a form in that way, it's even
possible to construct the form dynamically as the OP is doing it, that's why
Form.Controls is a public property and not a protected one.
Now, I do agree with you (and I said the same in the other post) that unless
needed adding the controls to a form through code is not the best idea, if
for any change the form change you could have to change lot of code all
aournd the place.
A better approach is to create your own form derived's class as you
suggest.
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:uL******** ******@TK2MSFTN GP12.phx.gbl... Well, first, you're going about this all wrong. You have a class that contains a form. You should create a class that IS a form, that is, inherits System.Windows. Forms.Form. There is no reason to put the form inside a class. You're putting a container inside a container. The class that holds the Windows Form class does nothing. Imagine, for example, that it's Christmas. Your brother gives you a presnt, a nicely wrapped box. You tear off the wrapping and open the box. Inside it is another box. You open that box, and your present is inside it. Why did your brother put the box with your present in it inside another box?
it sounds to me like you're no well-acquainted with Object-oriented programming. When you inherit a class, you are creating a new class that has all the characteristics of the old class, but with additional characteristics you define. So, you don't put a form inside a class. You inherit a Form class and write your own implementation of it.
Once you've done that, the Dialog form you've created handles the button's click event itself. After all, the button is a member of the form. If you want to do something with the data in the Dialog form in the form that opens it (by calling the ShowDialog method of the form, rather than having the form call its own ShowDialog method), you expose that data via a public, or internal property or method.
If you are serious about using .Net, study up on object-oriented programming principles, They make .Net powerful, and easy to use, if you employ them correctly.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Big things are made up of lots of little things.
"MounilK" <mo*****@maxit. com.au> wrote in message news:O8******** ******@TK2MSFTN GP10.phx.gbl... Hi Peter, Thanks for replying.Here's my code snippets
in the class library:-
public class MyClass { public void MyClassMethod() { frmParameterFor m = new System.Windows. Forms.Form(); System.Windows. Forms.Button myButton = new System.Windows. Forms.Button();
frmParameterFor m.Controls.Add( myButton); frmParameterFor m.ShowDialog(); } }
in the windows application WinApp:-
in the form1's button1's click event:
myClass cls = new myClass(); cls.MyClassMeth od();
What I would like to know is how can i now handle the click event of the form that was created by the cls.MyClassMeth od call? I am pretty new to this, so please excuse me if i sound naive.
Thanks, Mounil.
"Peter Rilling" <pe***@nospam.r illing.net> wrote in message news:eM******** ******@TK2MSFTN GP09.phx.gbl... What do you mean "access the click event"? Do you mean attach a handler to it or something?
Well, you might need to change your architecture a little. Maybe the method should return a reference to the form.
"MounilK" <mo*****@maxit. com.au> wrote in message news:u0******** ******@TK2MSFTN GP15.phx.gbl... Hi all, I am not sure if this is the right NG to post this question. If that's the case please point me to the correct NG.
I have a class library(myLib.d ll) which has a class(myClass) which has a method(myClassM ethod) that creates a form with a button on it. The application that calls the dll is a windows application(myW inApp).
When in myWinApp I do, myClass.myClass Method, a form is created.
What I would like to know is, how can i access the click event of the form that has been just created with the above call.
Thanks, Mounil.
Hi Ignacio,
As per your recommendations , I added a form to the dll.
now,
I have a DLL(myLib.dll) in which I have a form (myForm) On
myForm, I have a TabControl (myTabCtrl). I am creating a new tab-pages on
myTabCtrl at runtime; and on the tab-pages I am adding a DateTimePicker
control; On myForm I also have a command button (cmdClick). After the user
has selected the date on the DateTimePicker control and then clicks
cmdClick, I want to display a messagebox with the values of each
DateTimePicker on the various tab-pages. How do I do that? Pls help.
Thanking you,
Mounil.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:O0******** ******@TK2MSFTN GP15.phx.gbl... Hi,
You are not hooking the Control.Click event, do that and you will be fine.
Also I recommend you to create your own form with its controls and stuff, you can visually design it as a regular windows form even if your project is a dll
cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "MounilK" <mo*****@maxit. com.au> wrote in message news:O8******** ******@TK2MSFTN GP10.phx.gbl... Hi Peter, Thanks for replying.Here's my code snippets
in the class library:-
public class MyClass { public void MyClassMethod() { frmParameterFor m = new System.Windows. Forms.Form(); System.Windows. Forms.Button myButton = new System.Windows. Forms.Button();
frmParameterFor m.Controls.Add( myButton); frmParameterFor m.ShowDialog(); } }
in the windows application WinApp:-
in the form1's button1's click event:
myClass cls = new myClass(); cls.MyClassMeth od();
What I would like to know is how can i now handle the click event of the form that was created by the cls.MyClassMeth od call? I am pretty new to this, so please excuse me if i sound naive.
Thanks, Mounil.
"Peter Rilling" <pe***@nospam.r illing.net> wrote in message news:eM******** ******@TK2MSFTN GP09.phx.gbl... What do you mean "access the click event"? Do you mean attach a handler to it or something?
Well, you might need to change your architecture a little. Maybe the method should return a reference to the form.
"MounilK" <mo*****@maxit. com.au> wrote in message news:u0******** ******@TK2MSFTN GP15.phx.gbl... Hi all, I am not sure if this is the right NG to post this question. If that's the case please point me to the correct NG.
I have a class library(myLib.d ll) which has a class(myClass) which has a method(myClassM ethod) that creates a form with a button on it. The application that calls the dll is a windows application(myW inApp).
When in myWinApp I do, myClass.myClass Method, a form is created.
What I would like to know is, how can i access the click event of the form that has been just created with the above call.
Thanks, Mounil.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: KK |
last post by:
Windows Forms Inheritance, Incomplete?
I was playing around with Windows Forms
and found out this Forms Inheritance feature.
The moment I saw that, I felt this can be
used effectively if the application
contains couople of forms which have
a consistant look and also shares
SOME similar functionality between the forms.
|
by: Hamed |
last post by:
Hello
I have employed as a developer in a software company that its team uses
FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to
migrate to VS.NET. There is a project modified that is to upgrade a big,
more than 100,000 lines DOS based program developed by FoxPro 2.x to .NET
platform. The design is as previous and the implementation will be
reprogrammed. As a duty in my job I should find an answer about the
|
by: Nick |
last post by:
I am working a new application...well actually a series of applications for
my company. They want internal users to be able to go to a site and
everything regarding security is transparent, however we will have brokers
and customers that also need to connect and will require a username and
password. In this case we were going to store their credentials in a SQL
database. Internal users will have the ability to access the same resources...
|
by: Markus Eßmayr |
last post by:
Hello,
I'm writing an extension class for the winforms button control using MC++.
I created a class, derived from System::Windows::Forms::Button.
In my class I want to extend the functionality of the Image-property, so I
added the followind functions:
public __gc class ExtendedButton : public System::Windows::Forms::Button
{
public:
|
by: Andrew |
last post by:
Hey all,
I would like to preface my question by stating I am still learning ASP.net
and while I am confident in the basics and foundation, the more advanced
stuff is still a challenge. Ok. :)
| |
by: Alison |
last post by:
Hi, Al
I am trying to design a user interface which provides both menus and toolbars for some users to click on whatever they want to do, at the same time, I would like to have a console window available in the same form for users to enter commands and display outputs if some prefer to use character based user interface. I would like to implement the user interface in vb .net. Now I have menus and toolbars ready, but do not now how to get a...
|
by: Neal |
last post by:
managed C++
VS 2003
I have a beginner question about windows forms....
I need to call a function when a certain limit has been reached, now with
the way VS sets up the .NET windows Form I get confused. When I was using
Directx everything was being run from a while loop, so that was no problem
for me in seeing where to place conditional statements and other functions.
With windows forms do I need to have an event and eventhandler? it...
|
by: Dan Tallent |
last post by:
In my application I have a form (Customer) that I want to be able to open
multiple copies at once. Within this form I have other forms that can be
opened. Example: ZipCode. When the user enters a zipcode that is unknown
this form will open. I don't want users to modify any of this customers
data until they close the zipcode form. Normally this can accomplished
using a modal form, however this prevents me from opening a new copy of...
|
by: Scott Stark |
last post by:
Hello,
I'm *just* delving into Windows forms-based programming without the benefit
of any books, etc. I have a background in light ASP.NET work, so forgive me
if this is a really basic question related to Windows GUI.
I've created a "Form1.vb" file in my project, added a menustrip, etc. When a
user clicks on a menu item, how do I get it to show a new form in the same
window?
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |