简体   繁体   中英

Handle Multiple DataGridViews In one Script?

I have multiple datagridviews (DGVs) nestled in a tab control. I was trying to find a way to handle all the actions where I want to take identical steps in the same location. For example:

Sub DGV_UniversalAddRow Handles AnyDataGridView.UserAddedRow

'vs'

Sub DGV1_AddRow Handles DGV1.UserAddedRow

I've figured out that you can make lists and arrays of all the DGVs you have in a project, but I can't figure out how to access the user actions from these? Any hints, terms, or MS articles where this is addressed would be wonderful. I'd be happy to have the answer in C# instead if that helps.

Thanks!

You can handle multiple events with one handles argument. IE,

Sub DGV_UniversalAddRow Handles DataGridView1.UserAddedRow, DataGridView2.UserAddedRow, DataGridView3.UserAddedRow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM