[英]how to get the name of active datagridview
Good day guys, I have 5 datagridview which is bind in 5 different binding source. 大家好,我有5个datagridview绑定在5个不同的绑定源中。
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. 这是刷新datagridview中的数据的方式,我将删除datagrid视图的数据源,然后再次设置数据源。
anyone there can help me,.. thanks in advace :) 那里的任何人都可以帮助我,..谢谢advace :)
try this.. 尝试这个..
yourDatagridview.Name yourDatagridview.Name
In your event handler datagridview_DoubleClick
you can get a reference to datagridview where was double clicked. 在事件处理程序datagridview_DoubleClick
您可以获取对双击了datagridview的引用。 So you can have only one handler for all 5 datagridviews. 因此,所有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 在此处理程序中,您可以将DataGridView
引用放入您的Edit表单中(在使用DataGridView的参数创建Edit表单的构造函数之前),或者仅按要求获取DatagridView的名称。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.