• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 53
  • Last Modified:

Addhandler directcast

Hello,

Any suggestions on how can I use a addhandler directcast for the below repetitive code .

Private Sub DgClinic_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DgClinic.CellMouseClick
        CellMouseClick(sender, e)
    End Sub
    Private Sub DgCorr_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DgCorr.CellMouseClick
        CellMouseClick(sender, e)
    End Sub
    Private Sub DgDiary_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DgDiary.CellMouseClick
        CellMouseClick(sender, e)
    End Sub
    Private Sub DgContactdir_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DgContactsDir.CellMouseClick
        CellMouseClick(sender, e)
    End Sub
    Private Sub DgContactsIntDir_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DgContactsIntDir.CellMouseClick
        CellMouseClick(sender, e)
    End Sub


Cheers
0
RIAS
Asked:
RIAS
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
you can add multiple control to the Handles clause:

Private Sub CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DgClinic.CellMouseClick, DgCorr.CellMouseClick, DgDiary.CellMouseClick, DgContactsDir.CellMouseClick, DgContactsIntDir.CellMouseClick
        CellMouseClick(sender, e)
    End Sub

Open in new window

1
 
RIASAuthor Commented:
Cheers!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now