add eventhandler at runtime in VB

S

SteveR

I want to add an imagebutton control into a datagrid at runtime and use the
click event to navigate to another page. I can do this in C#
imagebutton.click += new eventhandler... but how do I do this in VB?
 
A

Alvin Bruney [MVP]

C#
this.openFile.FileOk += New
System.ComponentModel.CancelEventHandler(this.openFile_FileOk);

VB.NET
Me.openFile.FileOk += New
System.ComponentModel.CancelEventHandler(Me.openFile_FileOk)

I used Kamal's site for the conversion
http://www.kamalpatel.net/ConvertCSharp2VB.aspx

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
 
S

SteveR

Where do I have to add this? I want to add it in the ItemDataBound event of a
datagrid but the intellisense doesn't list any of the events to add an event
handler to. In fact I can't find anywhere where intellisense gives access to
any of the events in the way you describe. (C# does it but this project is
already well underway using VB so changing the language now isn't an option)
Steve


Alvin Bruney said:
C#
this.openFile.FileOk += New
System.ComponentModel.CancelEventHandler(this.openFile_FileOk);

VB.NET
Me.openFile.FileOk += New
System.ComponentModel.CancelEventHandler(Me.openFile_FileOk)

I used Kamal's site for the conversion
http://www.kamalpatel.net/ConvertCSharp2VB.aspx

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


SteveR said:
I want to add an imagebutton control into a datagrid at runtime and use the
click event to navigate to another page. I can do this in C#
imagebutton.click += new eventhandler... but how do I do this in VB?
 
S

SteveR

I found out how to do it, you have to add:

AddHandler tmpButton.Click, AddressOf myClick

the definition of myClick is:

Private Sub myClick(ByVal sender As System.Object, ByVal e As
System.EventArgs)

SteveR said:
Where do I have to add this? I want to add it in the ItemDataBound event of a
datagrid but the intellisense doesn't list any of the events to add an event
handler to. In fact I can't find anywhere where intellisense gives access to
any of the events in the way you describe. (C# does it but this project is
already well underway using VB so changing the language now isn't an option)
Steve


Alvin Bruney said:
C#
this.openFile.FileOk += New
System.ComponentModel.CancelEventHandler(this.openFile_FileOk);

VB.NET
Me.openFile.FileOk += New
System.ComponentModel.CancelEventHandler(Me.openFile_FileOk)

I used Kamal's site for the conversion
http://www.kamalpatel.net/ConvertCSharp2VB.aspx

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://tinyurl.com/27cok
----------------------------------------------------------


SteveR said:
I want to add an imagebutton control into a datagrid at runtime and use the
click event to navigate to another page. I can do this in C#
imagebutton.click += new eventhandler... but how do I do this in VB?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top