473,671 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about inherit form

Form1:
//-----------------------------------------------------------------
public class Form1 : System.Windows. Forms.Form
{
private System.Windows. Forms.TextBox textBox1;
private System.Componen tModel.IContain er components = null;

public Form1()
{
// This call is required by the Windows Form Designer.
InitializeCompo nent();

// TODO: Add any initialization after the InitializeCompo nent call
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
}
#endregion

protected void TextBox_Integer _KeyPress(objec t sender,
System.Windows. Forms.KeyPressE ventArgs e)
{
e.Handled=!Char .IsDigit(e.KeyC har);
}
}

Form2:
//-----------------------------------------------------------------
public class Form2 : Form1
{
private System.Windows. Forms.TextBox textBox1;
private System.Componen tModel.IContain er components = null;

public Form2()
{
// This call is required by the Windows Form Designer.
InitializeCompo nent();

// TODO: Add any initialization after the InitializeCompo nent call
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.textBox1 = new System.Windows. Forms.TextBox() ;
this.SuspendLay out();
this.textBox1.L ocation = new System.Drawing. Point(64, 56);
this.textBox1.N ame = "textBox1";
this.textBox1.S ize = new System.Drawing. Size(280, 20);
this.textBox1.T abIndex = 2;
this.textBox1.T ext = "";
this.ResumeLayo ut(false);
}
#endregion
}
//-----------------------------------------------------------------
I want to let Form2.TextBox1 assign the KeyPress event to
Form1.TextBox_I nteger_KeyPress , I can do that like this:
this.textBox1.K eyPress += new
System.Windows. Forms.KeyPressE ventHandler(thi s.TextBox_Integ er_KeyPress);

But HOW to specify the event in IDE("Properties Toolbar")?
Nov 16 '05 #1
2 1988
You have to switch in the event menu (the yellow lightning on top of the
property toolbar)

"afatdog" <af********@yea h.net> schrieb im Newsbeitrag
news:uP******** ******@tk2msftn gp13.phx.gbl...
Form1:
//-----------------------------------------------------------------
public class Form1 : System.Windows. Forms.Form
{
private System.Windows. Forms.TextBox textBox1;
private System.Componen tModel.IContain er components = null;

public Form1()
{
// This call is required by the Windows Form Designer.
InitializeCompo nent();

// TODO: Add any initialization after the InitializeCompo nent call
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
}
#endregion

protected void TextBox_Integer _KeyPress(objec t sender,
System.Windows. Forms.KeyPressE ventArgs e)
{
e.Handled=!Char .IsDigit(e.KeyC har);
}
}

Form2:
//-----------------------------------------------------------------
public class Form2 : Form1
{
private System.Windows. Forms.TextBox textBox1;
private System.Componen tModel.IContain er components = null;

public Form2()
{
// This call is required by the Windows Form Designer.
InitializeCompo nent();

// TODO: Add any initialization after the InitializeCompo nent call
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.textBox1 = new System.Windows. Forms.TextBox() ;
this.SuspendLay out();
this.textBox1.L ocation = new System.Drawing. Point(64, 56);
this.textBox1.N ame = "textBox1";
this.textBox1.S ize = new System.Drawing. Size(280, 20);
this.textBox1.T abIndex = 2;
this.textBox1.T ext = "";
this.ResumeLayo ut(false);
}
#endregion
}
//-----------------------------------------------------------------
I want to let Form2.TextBox1 assign the KeyPress event to
Form1.TextBox_I nteger_KeyPress , I can do that like this:
this.textBox1.K eyPress += new
System.Windows. Forms.KeyPressE ventHandler(thi s.TextBox_Integ er_KeyPress);

But HOW to specify the event in IDE("Properties Toolbar")?

Nov 16 '05 #2
I know the "yellow lighting", but I CAN NOT find the even in KeyPress's drop
down list :)
You have to switch in the event menu (the yellow lightning on top of the
property toolbar)

Nov 16 '05 #3

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

Similar topics

0
1939
by: Franco Gustavo | last post by:
Hi I have a Architecture question. (Put the text on courier new font to understand the graphic) Imagine that you have the next objects: A = Form B = Panel C = ButtonEx inherit from Button D = BUtton
3
1343
by: zbiszko | last post by:
I have such problem:) i have xml file: <?xml version="1.0" encoding="UTF-8"?> <doc> <page name="title1"/> <page name="title2" inherit="title1"/> <page name="title3"/> <page name="title4" inherit="title2"/> </doc>
7
1909
by: MounilK | last post by:
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.dll) which has a class(myClass) which has a method(myClassMethod) that creates a form with a button on it. The application that calls the dll is a windows application(myWinApp). When in myWinApp I do, myClass.myClassMethod, a form is created.
7
1259
by: Joe Fallon | last post by:
I have a WinForm that is a Base class. It has many controls on it and a lot of generic code behind. When I inherit the form I override 5 methods and now each child form has the same look and feel and functionality. This part all works fine. (I learned this morning that if you override a method that also has an Event Handler then you should NOT include the event handler a 2nd time. I had a devil of a time figuring out why a block of code...
5
1103
by: Christian Soltenborn | last post by:
Hi folks, I'm from the Java world, and I want to play a little bit with VB .NET. I have a simple question: In Java it is kind of common to have a static main method which does nothing else then creating an object of the class it belongs to and then to fall asleep. All real work will be done in the object. If the program quits, it does this with System.exit(int). How do I do something like this in VB .NET? I have source like this:
8
1694
by: Issac | last post by:
Hi, I created an Inherit UserControl which inherits textbox with additional property say 'Type'. I used in my forms and everything works fine. But afterward, I want to remove (or rename) such property. I find that the auto inserted code (InitializeComponent) for that UserControl's property doesn't get update, and I got tons of errors from wherever I referenced it. Do I need to manually update InitializeComponent module in every...
105
5297
by: Christoph Zwerschke | last post by:
Sometimes I find myself stumbling over Python issues which have to do with what I perceive as a lack of orthogonality. For instance, I just wanted to use the index() method on a tuple which does not work. It only works on lists and strings, for no obvious reason. Why not on all sequence types? Or, another example, the index() method has start and end parameters for lists and strings. The count() method also has start and end parameters...
37
1507
by: Gregory Guthrie | last post by:
I am comparing Python to a few other scripting languages, and used a simple anagrams program as a sample. I was surprised ast a few python features that did not work as I would expect/wish; which caused less compact/expressive program styles that I wanted - reverting to a FORTRAN like series of assignments. For example, - why is len() not a member function of strings? Instead one says len(w).
7
1591
by: Localbar | last post by:
Hi all, In my form have more then 10 textbox. I would like to make all textbox when lostfocus backcolor is white, when gotfocus backcolor is yellow. But I don't want to write same code in the form. How to solve this problem. Is it can make a textbox class to control or some other method? Thanks
9
1796
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?
0
8393
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
8820
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
8598
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
8670
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...
1
6223
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
5695
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
4224
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
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
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 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.