Data grid even handler firing multiple times

  • Thread starter Jonathan Crawford
  • Start date
J

Jonathan Crawford

Hi

I have a data grid with a fdata button which has three event handlers
I set the event handlers in code when I reset the table style. This works
perfectly
the first time. Unfortunately I have to reset the tablestyles regularly.
Each time
this happens something goes wrong and and HandleCellButtonClick event fires
an extra time. So if I set reset the table stles 5 time when I click the
button in
the datagrid, it is the eqivalent of clicking it five times (ie five
messageboxes)

I have tried removing the events before creating them, but this has not
effect

I am at a loss to understand this and can find no reason for this

Please, i would be grateful for some assistence

thanks

jonathan

Private WithEvents buttonColStyle As
DataGridButtonColumn....

buttonColStyle = New DataGridButtonColumn(i)
buttonColStyle.HeaderText =
_dataSet.Tables("customers").Columns(i).ColumnName
buttonColStyle.MappingName =
_dataSet.Tables("customers").Columns(i).ColumnName
RemoveHandler buttonColStyle.CellButtonClicked,
AddressOf HandleCellButtonClick
AddHandler buttonColStyle.CellButtonClicked, AddressOf
HandleCellButtonClick
tableStyle.GridColumnStyles.Add(buttonColStyle)

RemoveHandler dataGrid1.MouseDown, AddressOf
buttonColStyle.HandleMouseDown
RemoveHandler dataGrid1.MouseUp, AddressOf
buttonColStyle.HandleMouseUp
AddHandler dataGrid1.MouseDown, AddressOf
buttonColStyle.HandleMouseDown
AddHandler dataGrid1.MouseUp, AddressOf
buttonColStyle.HandleMouseUp


Private Sub HandleCellButtonClick(ByVal sender As Object, ByVal e As
DataGridCellButtonClickEventArgs)
MessageBox.Show(("row " + e.RowIndex.ToString() + " col " +
e.ColIndex.ToString() + " clicked."))
End Sub






===============
Jonathan Crawford
01273 440018
07799 068570
fax 01273 380221
(e-mail address removed)
===============
 
J

Jonathan Crawford

Hi
After further thought the problem must be with the class
DataGridButtonColumn which is creating multiple instances of the
buttonColStyle

I am afraid I have no idea how to stop this happening

Jonathan
 

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

Similar Threads


Top