views:

77

answers:

2

Hi,

I have gridviewname_CellClick(object sender, GridViewCellEventArgs e) event. I want this event to be called in Form load.

When i try

gridviewname_CellClick(sender,e)- i get exception as e as not an event of GridViewCellEventArgs, how to call this on form load?

Any inputs?

A: 

It can't be done. I suggest that you put your codes from GrisViewName_Click in another function then call that in your form load & GrisViewName_Click events.

hallie
Wrong. It can be done.
SLaks
Thanks hallie i did as you suggested , it worked fine. Thanks. I will also wait what SLaks approach would be. Thanks to both of you.
Karthick
A: 

In general, you should not call event handlers directly.
Instead, you should move the event handler code to a separate function, then call that function in the handler and wherever else you want.

To answer the question, you need to create your own GridViewCellEventArgs instance and pass it to the handler function.

SLaks
Thanks SLaks, Do you have any small sample so that i can refer and create mine (C#).
Karthick
What on earth do you mean? `new DataGridViewCellEventArgs(2, 3)`?
SLaks