Runtime, array of controls events | | |
I have the following code:
Dim myTextBox(10) As TextBox
Dim x As Integer
For x = 0 To 9
myTextBox(x) = New TextBox
With myTextBox(x)
Select Case x | | | | re: Runtime, array of controls events
Hi vbMark,
I dont see the events OnFocus or Onchange for a textbox.
But in general you create an addhandler for the events you'll need.
Hope this helps
"vbMark" <no@email.com> wrote in message
news:Xns95E162A4145A8noemailcom@130.133.1.4...[color=blue]
> I have the following code:
>
> Dim myTextBox(10) As TextBox
>
> Dim x As Integer
> For x = 0 To 9
>
> myTextBox(x) = New TextBox
> With myTextBox(x)
> Select Case x
> .
> . some code
> .
> End Select
> End With
>
> Me.Controls.Add(myTextBox(x))
>
> Next
>
> Now how do I get the OnFocus or OnChange events for myTextBox?
>
> Thanks![/color] | | | | re: Runtime, array of controls events
Sorry, I meant GotFocus and TextChanged.
"Pipo" <Pipo@nobody.com> wrote in news:OkBwTPK$EHA.3988
@TK2MSFTNGP11.phx.gbl:
[color=blue]
> Hi vbMark,
>
> I dont see the events OnFocus or Onchange for a textbox.
> But in general you create an addhandler for the events you'll need.
>
> Hope this helps
>
>
> "vbMark" <no@email.com> wrote in message
> news:Xns95E162A4145A8noemailcom@130.133.1.4...[color=green]
>> I have the following code:
>>
>> Dim myTextBox(10) As TextBox
>>
>> Dim x As Integer
>> For x = 0 To 9
>>
>> myTextBox(x) = New TextBox
>> With myTextBox(x)
>> Select Case x
>> .
>> . some code
>> .
>> End Select
>> End With
>>
>> Me.Controls.Add(myTextBox(x))
>>
>> Next
>>
>> Now how do I get the OnFocus or OnChange events for myTextBox?
>>
>> Thanks![/color]
>
>
>[/color] | | | | re: Runtime, array of controls events
Hi vbMark,
Did you looked at addhandler?
Is your problem solved?
Greets,
"vbMark" <no@email.com> wrote in message
news:Xns95E1666955C4Anoemailcom@130.133.1.4...[color=blue]
> Sorry, I meant GotFocus and TextChanged.
>
>
> "Pipo" <Pipo@nobody.com> wrote in news:OkBwTPK$EHA.3988
> @TK2MSFTNGP11.phx.gbl:
>[color=green]
> > Hi vbMark,
> >
> > I dont see the events OnFocus or Onchange for a textbox.
> > But in general you create an addhandler for the events you'll need.
> >
> > Hope this helps
> >
> >
> > "vbMark" <no@email.com> wrote in message
> > news:Xns95E162A4145A8noemailcom@130.133.1.4...[color=darkred]
> >> I have the following code:
> >>
> >> Dim myTextBox(10) As TextBox
> >>
> >> Dim x As Integer
> >> For x = 0 To 9
> >>
> >> myTextBox(x) = New TextBox
> >> With myTextBox(x)
> >> Select Case x
> >> .
> >> . some code
> >> .
> >> End Select
> >> End With
> >>
> >> Me.Controls.Add(myTextBox(x))
> >>
> >> Next
> >>
> >> Now how do I get the OnFocus or OnChange events for myTextBox?
> >>
> >> Thanks![/color]
> >
> >
> >[/color]
>[/color] | | | | re: Runtime, array of controls events
vbMark
\\\
For Each ctr as TextBox In myTextBox
AddHandler ctr.GotFocus, AddressOf meGotFocus
AddHandler ctr.TextChanged, AddressOf meTextChanged
Next
///
I hope this helps?
Cor | | | | re: Runtime, array of controls events
I think addhandler may be what I'm looking for. First tests look good.
I'll contine trying it out.
Thanks!
"Pipo" <Pipo@nobody.com> wrote in news:ODc12ZK$EHA.1084
@tk2msftngp13.phx.gbl:
[color=blue]
> Hi vbMark,
>
> Did you looked at addhandler?
> Is your problem solved?
>
> Greets,
>
>
> "vbMark" <no@email.com> wrote in message
> news:Xns95E1666955C4Anoemailcom@130.133.1.4...[color=green]
>> Sorry, I meant GotFocus and TextChanged.
>>
>>
>> "Pipo" <Pipo@nobody.com> wrote in news:OkBwTPK$EHA.3988
>> @TK2MSFTNGP11.phx.gbl:
>>[color=darkred]
>> > Hi vbMark,
>> >
>> > I dont see the events OnFocus or Onchange for a textbox.
>> > But in general you create an addhandler for the events you'll need.
>> >
>> > Hope this helps
>> >
>> >
>> > "vbMark" <no@email.com> wrote in message
>> > news:Xns95E162A4145A8noemailcom@130.133.1.4...
>> >> I have the following code:
>> >>
>> >> Dim myTextBox(10) As TextBox
>> >>
>> >> Dim x As Integer
>> >> For x = 0 To 9
>> >>
>> >> myTextBox(x) = New TextBox
>> >> With myTextBox(x)
>> >> Select Case x
>> >> .
>> >> . some code
>> >> .
>> >> End Select
>> >> End With
>> >>
>> >> Me.Controls.Add(myTextBox(x))
>> >>
>> >> Next
>> >>
>> >> Now how do I get the OnFocus or OnChange events for myTextBox?
>> >>
>> >> Thanks!
>> >
>> >
>> >[/color]
>>[/color]
>
>
>[/color] | | | | re: Runtime, array of controls events
"Cor Ligthert" <notmyfirstname@planet.nl> wrote in news:#WKBRfK$EHA.3820
@TK2MSFTNGP11.phx.gbl:
[color=blue]
> vbMark
>
> \\\
> For Each ctr as TextBox In myTextBox
> AddHandler ctr.GotFocus, AddressOf meGotFocus
> AddHandler ctr.TextChanged, AddressOf meTextChanged
> Next
> ///
>
> I hope this helps?
>
> Cor
>
>[/color]
Ok, using AddHandler works and creates the event. Now how do I know which
control in the array fired the event?
I have this in my loop:
AddHandler myTextBox(x).GotFocus, AddressOf myTextBox_GotFocus
And this Sub:
Sub myTextBox_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs)
????
End Sub
Thanks. | | | | re: Runtime, array of controls events
vbMark,
In this situation I gave every control a name before I add them to the form.
\\\
myTextBox.Name=x.ToString
Me.Controls.Add(myTextBox(x))
///
Then you can do by instance in the event
\\\
Sub myTextBox_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs)
Select Case DirectCast(sender,TextBox).Name
Case "0"
'do something
Case "1"
End Sub
///
I hope this helps?
Cor | | | | re: Runtime, array of controls events
Excellent! Thanks!
"Cor Ligthert" <notmyfirstname@planet.nl> wrote in
news:#zIyU8L$EHA.3988@TK2MSFTNGP11.phx.gbl:
[color=blue]
> vbMark,
>
> In this situation I gave every control a name before I add them to the
> form.
>
> \\\
> myTextBox.Name=x.ToString
> Me.Controls.Add(myTextBox(x))
> ///
>
> Then you can do by instance in the event
>
> \\\
> Sub myTextBox_GotFocus(ByVal sender As Object, ByVal e As
> System.EventArgs)
> Select Case DirectCast(sender,TextBox).Name
> Case "0"
> 'do something
> Case "1"
> End Sub
> ///
>
> I hope this helps?
>
> Cor
>
>
>[/color] |  | Similar Visual Basic .NET bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,358 network members.
|