How to Add event in the dynamic Gridview control?


Hi guys,

i am facing a problem which is i need to create a dynamic gridview control and i need to add eventhandler for this gridview. Therefore, how i add the event?


are you creating that gridview at runtime?
then your could add a global declaration: Private withevents dataGV as datagridview after this you can already find the events for that control just as all others.
and use it on runtime like: dataGV = new gridview


Use AddHandler and RemoveHandler to add or remove event handlers dynamically.


use add handler


addhandler , addressof event

sub event(ByVal sender As System.Object, ByVal e As System.EventArgs)


end sub

suppose the event you want when gridview clicked
and what you want to do put it in another sub

This article has been dead for over six months: Start a new discussion instead
Start New Discussion
Tags Related to this Article