473,322 Members | 1,379 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,322 software developers and data experts.

Question about inherit form

Form1:
//-----------------------------------------------------------------
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.IContainer components = null;

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

// TODO: Add any initialization after the InitializeComponent call
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
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 InitializeComponent()
{
}
#endregion

protected void TextBox_Integer_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
e.Handled=!Char.IsDigit(e.KeyChar);
}
}

Form2:
//-----------------------------------------------------------------
public class Form2 : Form1
{
private System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.IContainer components = null;

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

// TODO: Add any initialization after the InitializeComponent call
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
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 InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
this.textBox1.Location = new System.Drawing.Point(64, 56);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(280, 20);
this.textBox1.TabIndex = 2;
this.textBox1.Text = "";
this.ResumeLayout(false);
}
#endregion
}
//-----------------------------------------------------------------
I want to let Form2.TextBox1 assign the KeyPress event to
Form1.TextBox_Integer_KeyPress, I can do that like this:
this.textBox1.KeyPress += new
System.Windows.Forms.KeyPressEventHandler(this.Tex tBox_Integer_KeyPress);

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

"afatdog" <af********@yeah.net> schrieb im Newsbeitrag
news:uP**************@tk2msftngp13.phx.gbl...
Form1:
//-----------------------------------------------------------------
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.IContainer components = null;

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

// TODO: Add any initialization after the InitializeComponent call
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
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 InitializeComponent()
{
}
#endregion

protected void TextBox_Integer_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
e.Handled=!Char.IsDigit(e.KeyChar);
}
}

Form2:
//-----------------------------------------------------------------
public class Form2 : Form1
{
private System.Windows.Forms.TextBox textBox1;
private System.ComponentModel.IContainer components = null;

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

// TODO: Add any initialization after the InitializeComponent call
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
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 InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
this.textBox1.Location = new System.Drawing.Point(64, 56);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(280, 20);
this.textBox1.TabIndex = 2;
this.textBox1.Text = "";
this.ResumeLayout(false);
}
#endregion
}
//-----------------------------------------------------------------
I want to let Form2.TextBox1 assign the KeyPress event to
Form1.TextBox_Integer_KeyPress, I can do that like this:
this.textBox1.KeyPress += new
System.Windows.Forms.KeyPressEventHandler(this.Tex tBox_Integer_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
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...
3
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"...
7
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...
7
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...
5
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...
8
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...
105
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...
37
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;...
7
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...
9
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.