I have a piece of code thus:
For iLOOP = 0 To iNoDays - 1
For jLOOP = 0 To iMaxPeriods - 1
iX = 10 + (iLOOP * (dCellWidth + 10))
iY = 10 + (jLOOP * (dCellHeight + 10)) +
Me.Size.Height / 4
If jLOOP = 0 And iLOOP = 0 Then
lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP) = New
TextBox
lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Text =
" "
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Location = New Point(iX, iY)
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).AutoSize = False
lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Height
= dCellHeight
lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Width
= dCellWidth
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Visible = False
lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Name =
"txtPERIOD" & ((iLOOP) * iMaxPeriods) + jLOOP.ToString
Me.Controls.Add (lblDISPLAY(((i LOOP) * iMaxPeriods)
+ jLOOP))
Else
If jLOOP = 0 And iLOOP > 0 Then
lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP) =
New TextBox
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Text = WeekdayName(iLO OP, , FirstDayOfWeek. Sunday)
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Location = New Point(iX, iY)
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Height = dCellHeight
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Width = dCellWidth
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).AutoSize = False
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).BorderSt yle = BorderStyle.Non e
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).TextAlig n = HorizontalAlign ment.Center
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Name = "txtPERIOD" & ((iLOOP) * iMaxPeriods) + jLOOP.ToString
Me.Controls.Add (lblDISPLAY(((i LOOP) *
iMaxPeriods) + jLOOP))
Else
If iLOOP = 0 And jLOOP > 0 Then
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP) = New TextBox
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Text = "Period " & jLOOP.ToString
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Location = New Point(iX, iY)
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Height = dCellHeight
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Width = dCellWidth
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).AutoSize = False
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).BorderSt yle = BorderStyle.Non e
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).TextAlig n = HorizontalAlign ment.Right
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Name = "txtPERIOD" & ((iLOOP) * iMaxPeriods) + jLOOP.ToString
Me.Controls.Add (lblDISPLAY(((i LOOP) *
iMaxPeriods) + jLOOP))
Else
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP) = New TextBox
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Text = "Label No " & ((iLOOP) * iMaxPeriods) + jLOOP.ToString
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Location = New Point(iX, iY)
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Height = dCellHeight
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Width = dCellWidth
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).AutoSize = False
lblDISPLAY(((iL OOP) * iMaxPeriods) +
jLOOP).Name = "txtPERIOD" & ((iLOOP) * iMaxPeriods) + jLOOP.ToString
Me.Controls.Add (lblDISPLAY(((i LOOP) *
iMaxPeriods) + jLOOP))
End If
End If
End If
Next jLOOP
Next iLOOP
which creates a grid of text boxes on a form at runtime dependent on
the number of days and the number of periods - its a timetable sort of
thing.
How do I capture events for these controls?
such as
private sub lblDISPLAY(((iL OOP) * iMaxPeriods)_Mo useclick
or
private sub lblDISPLAY(((iL OOP) * iMaxPeriods)_go tfocus
?? 16 1212
Tym,
You can use AddHandler & RemoveHandler, something like:
Dim index As Integer = ((iLOOP) * iMaxPeriods) + jLOOP
AddHandler lblDISPLAY(inde x).Click, AddressOf labelDisplay_Cl ick
AddHandler lblDISPLAY(inde x).GotFocus, AddressOf
labelDisplay_Go tFocus
Private Sub labelDisplay_Cl ick(ByVal sender As Object, ByVal e As
System.EventArg s)
End Sub
Private Sub labelDisplay_Go tFocus(ByVal sender As Object, ByVal e As
System.EventArg s)
End Sub
Hope this helps
Jay
"Tym" <no*****@ictis. net> wrote in message
news:5l******** *************** *********@4ax.c om... I have a piece of code thus:
For iLOOP = 0 To iNoDays - 1 For jLOOP = 0 To iMaxPeriods - 1 iX = 10 + (iLOOP * (dCellWidth + 10)) iY = 10 + (jLOOP * (dCellHeight + 10)) + Me.Size.Height / 4 If jLOOP = 0 And iLOOP = 0 Then lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP) = New TextBox lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Text = " " lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Location = New Point(iX, iY) lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).AutoSize = False lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Height = dCellHeight lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Width = dCellWidth lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Visible = False lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Name = "txtPERIOD" & ((iLOOP) * iMaxPeriods) + jLOOP.ToString Me.Controls.Add (lblDISPLAY(((i LOOP) * iMaxPeriods) + jLOOP)) Else If jLOOP = 0 And iLOOP > 0 Then lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP) = New TextBox lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Text = WeekdayName(iLO OP, , FirstDayOfWeek. Sunday) lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Location = New Point(iX, iY) lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Height = dCellHeight lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Width = dCellWidth lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).AutoSize = False lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).BorderSt yle = BorderStyle.Non e lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).TextAlig n = HorizontalAlign ment.Center lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Name = "txtPERIOD" & ((iLOOP) * iMaxPeriods) + jLOOP.ToString Me.Controls.Add (lblDISPLAY(((i LOOP) * iMaxPeriods) + jLOOP)) Else If iLOOP = 0 And jLOOP > 0 Then lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP) = New TextBox lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Text = "Period " & jLOOP.ToString lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Location = New Point(iX, iY) lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Height = dCellHeight lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Width = dCellWidth lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).AutoSize = False lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).BorderSt yle = BorderStyle.Non e lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).TextAlig n = HorizontalAlign ment.Right lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Name = "txtPERIOD" & ((iLOOP) * iMaxPeriods) + jLOOP.ToString Me.Controls.Add (lblDISPLAY(((i LOOP) * iMaxPeriods) + jLOOP)) Else lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP) = New TextBox lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Text = "Label No " & ((iLOOP) * iMaxPeriods) + jLOOP.ToString lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Location = New Point(iX, iY) lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Height = dCellHeight lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Width = dCellWidth lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).AutoSize = False lblDISPLAY(((iL OOP) * iMaxPeriods) + jLOOP).Name = "txtPERIOD" & ((iLOOP) * iMaxPeriods) + jLOOP.ToString Me.Controls.Add (lblDISPLAY(((i LOOP) * iMaxPeriods) + jLOOP)) End If End If End If Next jLOOP Next iLOOP
which creates a grid of text boxes on a form at runtime dependent on the number of days and the number of periods - its a timetable sort of thing.
How do I capture events for these controls? such as private sub lblDISPLAY(((iL OOP) * iMaxPeriods)_Mo useclick
or
private sub lblDISPLAY(((iL OOP) * iMaxPeriods)_go tfocus
??
Jay - excellent code - worked right out of the box!!
Just one further request - is there a way to detect which one has been
clicked??
advTHANKSance
On Tue, 2 Nov 2004 08:55:09 -0600, "Jay B. Harlow [MVP - Outlook]"
<Ja************ @msn.com> wrote: Private Sub labelDisplay_Cl ick(ByVal sender As Object, ByVal e As System.EventArg s)
msgbox ("You have clicked on cell number " & labelDISPLAY.Na me)
' you get the idea... :-)
End Sub
Tym,
The sender parameter will be the specific TextBox that sent the message.
If your handler only handles TextBox events (you only use AddHandler on
TextBox objects) you can use: Private Sub labelDisplay_Cl ick(ByVal sender As Object, ByVal e As System.EventA rgs)
Dim labelDISPLAY As TextBox = DirectCast(send er, TextBox) msgbox ("You have clicked on cell number " & labelDISPLAY.Na me) ' you get the idea... :-)
If you use AddHandler on different type of controls, then I would recommend
using either Control & limit the event to properties common to all Controls,
or use TypeOf...
Private Sub labelDisplay_Cl ick(ByVal sender As Object, ByVal e As System.EventA rgs)
Dim labelDISPLAY As Control = DirectCast(send er, Control)
-- or --
If TypeOf sender Is TextBox Then
Dim labelDISPLAY As TextBox = DirectCast(send er, TextBox)
...
ElseIf TypeOf sender Is ComboBox Then
Dim labelDISPLAY As ComboBox = DirectCast(send er, ComboBox)
...
End If
Hope this helps
Jay
"Tym" <bi********@mic rosoft.com> wrote in message
news:e7******** *************** *********@4ax.c om... Jay - excellent code - worked right out of the box!!
Just one further request - is there a way to detect which one has been clicked??
advTHANKSance
On Tue, 2 Nov 2004 08:55:09 -0600, "Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote:
Private Sub labelDisplay_Cl ick(ByVal sender As Object, ByVal e As System.EventA rgs)
msgbox ("You have clicked on cell number " & labelDISPLAY.Na me) ' you get the idea... :-)
End Sub
Jay - Thanks - this is working fine so far...
Private Sub labelDisplay_Cl ick(ByVal Sender As Object, ByVal e As
System.EventArg s)
Dim labelDISPLAY As TextBox = DirectCast(Send er, TextBox)
MsgBox("Just clicked on a box! " & labelDISPLAY.To String)
End Sub
but this returns the text within the text box. Is there a way to
detect the .name of the text box clicked on, rather than returning its
contents?
Thanks - your help is brilliant.
Tym
Have you tried using the Name property of labelDISPLAY? MsgBox("Just clicked on a box! " & labelDISPLAY.Na me)
Hope this helps
Jay
"Tym" <bi********@mic rosoft.com> wrote in message
news:jh******** *************** *********@4ax.c om... Jay - Thanks - this is working fine so far...
Private Sub labelDisplay_Cl ick(ByVal Sender As Object, ByVal e As System.EventArg s) Dim labelDISPLAY As TextBox = DirectCast(Send er, TextBox) MsgBox("Just clicked on a box! " & labelDISPLAY.To String) End Sub
but this returns the text within the text box. Is there a way to detect the .name of the text box clicked on, rather than returning its contents?
Thanks - your help is brilliant.
On Tue, 02 Nov 2004 17:40:58 +0000, Tym <bi********@mic rosoft.com>
wrote: but this returns the text within the text box. Is there a way to detect the .name of the text box clicked on, rather than returning its contents?
Thanks - your help is brilliant.
Jay - found it....
Private Sub labelDisplay_Cl ick(ByVal Sender As Object, ByVal e As
System.EventArg s)
Dim labelDISPLAY As TextBox = DirectCast(Send er, TextBox)
MsgBox("Just clicked on a box! " & labelDISPLAY.Na me.ToString)
End Sub
Just needed to experiment a little - thanks for your help!
Tym,
labelDISPLAY.Na me returns a string, there is no real need to call ToString
on it. MsgBox("Just clicked on a box! " & labelDISPLAY.Na me)
Hope this helps
Jay
"Tym" <bi********@mic rosoft.com> wrote in message
news:pi******** *************** *********@4ax.c om... On Tue, 02 Nov 2004 17:40:58 +0000, Tym <bi********@mic rosoft.com> wrote:
but this returns the text within the text box. Is there a way to detect the .name of the text box clicked on, rather than returning its contents?
Thanks - your help is brilliant.
Jay - found it....
Private Sub labelDisplay_Cl ick(ByVal Sender As Object, ByVal e As System.EventArg s) Dim labelDISPLAY As TextBox = DirectCast(Send er, TextBox) MsgBox("Just clicked on a box! " & labelDISPLAY.Na me.ToString) End Sub
Just needed to experiment a little - thanks for your help!
On Tue, 2 Nov 2004 17:06:00 -0600, "Jay B. Harlow [MVP - Outlook]"
<Ja************ @msn.com> wrote: labelDISPLAY.N ame returns a string, there is no real need to call ToString on it.
Yes - thanks. I realised that afterwards!!
Ok, so now I've got an event handler, how easy is it to refer to these
textboxes within my code elsewhere?
Normally, I would code:
If txtTextBox.Text = "Some Text" then
'my procedure....
End If
But as the name of the control is determined at runtime, I can't see a
straightworward way of doing this.
Sorry to bother you again... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: hybrid |
last post by:
I have problems in understanding the behavior of the events triggered by
dynamically created controls over a webform.
Could you help me?
In a webform, I have a static PlaceHolder PH containing a table of
controls, dynamically generated. Among these, a linkbutton (LinkBtn) to
which have attached a click handler method, LinkBtn_Click(...) .
Generally it works fine, but if in the LinkBtn_Click(...) code I try to
access a webform control,...
|
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 know exactly where the
table will be located on the page until runtime. Before the form control
table is added to the Placeholder, I'm adding a whole bunch of tables to the
Placeholder. This is a flowchart program and I have multiple action boxes...
|
by: karthick raja |
last post by:
Am experiencing a problem intercepting the events from controls added
dynamically to a Placeholder control at runtime.
Is there any way that I can write an event handler on the page which will be
pick up the events raised by the added controls dynamically.
I cannot use 'WithEvents' and 'Handles' because this requires that the
controls be declared on the page and they aren't (they are created in the
external class)
I did think of using...
|
by: Klaus Jensen |
last post by:
Hi!
This has been annoying me for a while now, and I can't get it to work It is
really
driving me nuts!
Basicly this simple webapp created to illustrate my problem, renders five
buttons, and adds a handler to the click event. When a button is clicked,
the background-color is set to blue.
|
by: krishna |
last post by:
Hi,
Hi,
I would like to handle the events for the dynamically
created controls at runtime.
I Have written the code in HTML View of an asp.net
page.like this
| |
by: Steve Moreno |
last post by:
Hi all,
I've got a web form that I've written code to create an array of
DropDownList controls on the page depending on how many records are pulled
back. The code to create the controls is working fine but now I need to add
events to the newly created DropDownList controls. I need to add the
SelectedIndexChanged event and I'm having a hard time getting the code to add
events to the controls since the names (IDs) are varied to include...
|
by: Bruce HS |
last post by:
I'd like to call my ancestor Validation Function every time any control on a
Win Form generates a Validating or Validated event. I'm using VB.
I've extended Textbox, for instance, to have its events do this for me, but
my extended textbox doesn't get created by those wonderful form setup wizards.
So,
1) Is there a way I can pick up these events without having to code for each
control and without using custom extended controls, OR
|
by: Jose Fernandez |
last post by:
Hello.
I would like to know how could i get all the subscriptions that my form has
with the events of their controls.
For example.
I have a form with a textbox, a button and a dropdown. I create a
subscription to the Click event of the Button and another to the
SelectedIndexChanged del dropDown.
|
by: Klaus Jensen |
last post by:
Subject: Handling events of controls created at runtime
I need to render some buttons at runtime based on a database, tie events to
them, and handle the events when they fire.
In Page_Load I create the controls (for example a delete-button), add them
to a placeholder, add eventhandlers, and the controls are displayed as
expected.
I click the button, the event fires as I wanted, I delete a record in the
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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...
|
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: 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();...
|
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: 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...
| |