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

Events with Dynamically created controls.

Everyone:

I have a WinForm in which I dynamically create tabs based on some user
input. Inside those tabs are some text boxes for data. I can do
everything but fire events properly. I have a click event for one of
the text boxes on each tab. When I click on the text box the event is
fired but I don't know how to check which text box on which tab has
been fired.

Thank you for the help.

Sincerely,
Dale Williams

I have the following code to add the text box to the tab:

// Add text box to display formulas, etc.
TextBox l_objTB = new TextBox();
l_objTB.Name = "txt-" + l_objSubRow["RFQQuantityId"].ToString() +
"-" + l_objSubRow["RecType"].ToString();
l_objTB.Enabled = true;
l_objTB.Width = 250;
l_objTB.Top = l_objSubTabCon.Top;
l_objTB.Click +=new EventHandler(l_objTB_Click);
l_objSubTabCon.TabPages[l_lSubLoop].Controls.Add(l_objTB);
I have the following click event for the text box.
private void l_objTB_Click(object sender, EventArgs e)
{
e.ToString();
}
Nov 16 '05 #1
1 1437
Hi Dale,
Reference to the text box comes in the sender parameter of the event
handler. To find out the page use TextBox.Parent property.

--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Dale Williams" <dw*******@odyssey-sw.com> wrote in message
news:2a**************************@posting.google.c om...
Everyone:

I have a WinForm in which I dynamically create tabs based on some user
input. Inside those tabs are some text boxes for data. I can do
everything but fire events properly. I have a click event for one of
the text boxes on each tab. When I click on the text box the event is
fired but I don't know how to check which text box on which tab has
been fired.

Thank you for the help.

Sincerely,
Dale Williams

I have the following code to add the text box to the tab:

// Add text box to display formulas, etc.
TextBox l_objTB = new TextBox();
l_objTB.Name = "txt-" + l_objSubRow["RFQQuantityId"].ToString() +
"-" + l_objSubRow["RecType"].ToString();
l_objTB.Enabled = true;
l_objTB.Width = 250;
l_objTB.Top = l_objSubTabCon.Top;
l_objTB.Click +=new EventHandler(l_objTB_Click);
l_objSubTabCon.TabPages[l_lSubLoop].Controls.Add(l_objTB);
I have the following click event for the text box.
private void l_objTB_Click(object sender, EventArgs e)
{
e.ToString();
}

Nov 16 '05 #2

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

Similar topics

3
by: Kenton Smeltzer | last post by:
Hello All, I am having a problem with events and the addition of controls on a page I am developing. First let me tell you what I have tried and then maybe someone can see something I missed. ...
4
by: blue | last post by:
I have a drop-down list, a radio button list and a submit button. I'm adding these controls to a table and I'm adding the table to a Placeholder. I'm adding it to the Placeholder because I don't...
1
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
2
by: Nathan Sokalski | last post by:
I have LinkButtons that are dynamically created in one of the PostBack events. They must be created in the PostBack event because one of the variables required to determine which ones to create...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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.