Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Addhandler directcast

Posted on 2016-08-23
2
40 Views
Last Modified: 2016-08-23
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
Comment
Question by:RIAS
2 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 41766865
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
 

Author Closing Comment

by:RIAS
ID: 41766898
Cheers!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question