Releasing an Event

R

Randy

Hello,
I've got a table and I create a tablestyle for it. This table is the
datasource for a dataGrid. In this createTableStyle function one of the
columns is a button. I tie a button to it.
buttonColStyle = new DataGridButtonColumn(i);

and a click event.
buttonColStyle.CellButtonClicked += new
DataGridCellButtonClickEventHandler(HandleCellButtonClick);

In the HandleCellButtonClick function, it calls another form.

This all works fine.except.

My problem is that on my main form I have a button which will pull new data
from a database and rebuild the table and tablestyle for the table. So, when
the above code is executed again, it ties another CellButtonClicked event to
the button. So now when I click the button in the datagrid and the form
comes up, I have to close it twice to get rid of it.
I've tried dataGrid1.TableStyles.Clear(); to maybe release it but that doesn
't work. Can someone tell me how to clear the events tied to a tableStyle?
Thanks to all...
 
J

Joyjit Mukherjee

Hi,

try using buttonColStyle.CellButtonClicked -= new
DataGridCellButtonClickEventHandler(HandleCellButtonClick) to unsubscribe
the event from the delegate.

Regards
Joyjit
 

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

Top