简体   繁体   中英

how to get the name of active datagridview

Good day guys, I have 5 datagridview which is bind in 5 different binding source.

After my edit function I want to refresh the datagrid or the dataset but I cant get the name of the active datagridview.

what i wanted to do after the edit is this :

(Active Datagridview)..DataSource = typeof(List); 

(Active Datagridview).DataSource = dataset.Tables["your table"]; 

this is my way to refresh the data in datagridview, I'll remove the datasource of datagrid view and set again the datasource.

anyone there can help me,.. thanks in advace :)

try this..

yourDatagridview.Name

In your event handler datagridview_DoubleClick you can get a reference to datagridview where was double clicked. So you can have only one handler for all 5 datagridviews. In this handler you can put reference of DataGridView to your Edit form(before create constructor of Edit form with parameter of DataGridView) or get only a name of DatagridView as you was asked

private sub datagridview_DoubleClick(sender as Object, e as EventArgs) Handle datagridview1.DoubleClick,
                                                                       datagridview2.DoubleClick,
                                                                       datagridview3.DoubleClick,                                                                              
                                                                       datagridview4.DoubleClick,
                                                                       datagridview5.DoubleClick
    Dim dgvClicked as DataGridView = DirectCast(sender, DataGridView)
    dim frmEdit as FormEdit = New FormEdit(dgvClicked)
    frmEdit.ShowDialog()
    ....

End Sub

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