473,796 Members | 2,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Wrapping a WinForm in a class

I have a winform that runs on its own, is it possible to wrap a stand-alone
winform in a class?

More accurately, is it possible to use a class to call an already
established winform?
Nov 21 '05 #1
2 1235
"Wayne" <no**@some.is p> schrieb:
I have a winform that runs on its own, is it possible to wrap a
stand-alone winform in a class?
Windows Forms forms are already classes.
More accurately, is it possible to use a class to call an already
established winform?


You will have to make a reference to your instance of the Windows Forms form
available to the class. If you are instantiating your class from within
your form, you can add a property of the form's type to the class and set
this property to 'Me'. If there is only max. one instance of the form, you
can implement the singleton design pattern in order to easily access the
form's instance.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2
Hi,

In addition to Herfeid's comments. You could try something like
this.

Public Class Form2
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "
Private Shared instance As Form2

Public Shared ReadOnly Property DefInstance() As Form2
Get
If instance Is Nothing Then instance = New Form2
Return instance
End Get
End Property
End Class

To use

Dim frm As Form2 = Form2.DefInstan ce
frm.ShowDialog( )

Ken
------------------
"Wayne" <no**@some.is p> wrote in message
news:uU******** ******@TK2MSFTN GP14.phx.gbl...
I have a winform that runs on its own, is it possible to wrap a stand-alone
winform in a class?

More accurately, is it possible to use a class to call an already
established winform?

Nov 21 '05 #3

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

Similar topics

1
2079
by: i | last post by:
Hi, I'm trying to get a seperate class, initialized by a form class, to manipulate certain objects on the form (ex: add to a listbox). The manipulation will occur via a thread that is not the normal WinForm GUI thread. How would I go about doing this? I have this code for cross-thread WinForm manipulation, but only from within the WinForm class:
2
1591
by: Andrzej Kaczmarczyk | last post by:
Hi I am experiencing something weird. maybe you could help me. I have two ineditable classes from outsource libraries: DataColumn and GridColumn I have built a wrapper class around DataColumn like this: public class MyDataColumn {
6
4758
by: William F. Kinsley | last post by:
I am thinking of porting an existing MFC application to MC++ and I have created a simple MFC application to test the environment. My sample MFC application is compilied with the /clr switch. I added a basic WinForm class(via the wizard). In my MFC WinApp class I have a menu message handler to display the standard About Dialog. In the message handler I create, show and close the window. Everything appears to be working fine until I close...
5
1621
by: Lee Crabtree | last post by:
More fun wrapping unmanaged code... I have a class heirarchy that I need to expose to C#, so I need to wrap all the classes. That's not a big deal, except for the base class, which is abstract. Since you can't instantiate an abstract class, I can't use a pointer to the unmanaged type to handle the function calls. Is there a good way to do this? Lee
10
2388
by: Tom the Canuck | last post by:
What would be the best way to proceed? Should I make a pure virtual class and then derive from that? I want the base class to have functions defined so that I don't have to do the work all over again in the derived class. Is this not what objects are for? Please illuminate on how to do this properly. I don't want code, just a pointer on how to do the job right. Any comments or links will help.
8
13870
by: Nathan | last post by:
I am trying to prevent a horizontal list from wrapping. Each list item is floated with "float: left". Currently I use an ugly hack. I set the width of the list to a large number which is guananteed greater than the total width of all items. Is there a way to accomplish this without my hack? It would be handy because I would like to read the total width of all items in javascript. I looked into white-space: nowrap, but it doesn't work...
3
2886
by: gabriel.becedillas | last post by:
Hi, I'm having problems wrapping a hierarchy of classes, actually having problems wrapping the base class. I don't need to use the WrapClass mechanism since I don't want to override classes in Python. My code boils down to: class Base { public: virtual ~Base()
4
1440
by: Mark Baldwin | last post by:
I have an application with both Windows Forms and ASP.NET front ends and uses both integrated web security and a security database. The problem I have is that I need to syncronize these security databases. The web front end uses ASP membership with the SQL provider, the database is moved to the SQL Server instead of the SQL Express datafile. The Windows Forms app uses tables such as "users" within the database. If I add a user on the...
2
3741
by: jyanmin.fang | last post by:
Hi, In my current project, I need to embed an .NET winform usercontrol in the aspx page (via <Objecttag). This winform usercontrol has an event called DoEvent (void DoEvent()). This winform usercontrol will fire this event upon certain action by the user. I tried to let the aspx page subscribe to this event via <script for="winObj1" event="DoEvent()" language="javascript"> window.alert("window control event happen!");
0
9524
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
10449
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
10217
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
10168
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,...
1
7546
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
5440
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...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
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
3730
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.