Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing A function Address

Status
Not open for further replies.

mbde

Programmer
Mar 14, 2005
55
US
I have a form that has a function, HandleCellButtonClick, that I hook up to an event

buttonColumn.CellButtonClicked +=
new CustomGridColumns.DataGridCellButtonClickEventHandler(HandleCellButtonClick);

That works fine HandleCellButtonClick has the signature of DataGridCellButtonClickEventHandler

Where this all goes wrong is if I take the code out of the form and put it in a controller class so that the function looks something like this


public static SetGrid(DataTable dt, DataGrid dg, (???) dHandleClick)
{
.
.
.
buttonColumn.CellButtonClicked +=
new CustomGridColumns.DataGridCellButtonClickEventHandler(dHandleClick);

}

What type of variable do I name the last Parameter so I can make the call

Controller.SetupGrid(dtCustomer, dgCustomer, HandleCellButtonClick);

Thus hooking up the function on the form to the event of a grid column.

I tried void(object, DataGridCellButtonClickEventHandler), the reason I choose this route is in the intella-sense of other eventhandlers you will see "void(object, EventArgs) target" as the parameter type, but the compiler does not like void() as a type.
 
Thank you for the reply and the resource on reflection.

To solve my immediate problem I just pass in the whole right side

so inside the function looks like
buttonColumn.CellButtonClicked += dHandleClick

and the call is
Controller.SetupGrid(dtCustomer, dgCustomer, new CustomGridColumns.DataGridCellButtonClickEventHandler(HandleCellButtonClick));

This idea was given by another poster on the gotdotnet boards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top