尝试获取选项卡名称时出错

时间:2017-06-02 02:58:47

标签: c# datagridview

我想在事件datagridview上获取tab_SelectedIndexChanged名称 如下所示,但我收到错误消息

  

无法转换为' string'到' System.Windows.Forms.DataGridView'

无论如何,我可以帮助我

    public static string Selected_dgvName;

    private void tab_SelectedIndexChanged(object sender, EventArgs e)
    {
        Selected_dgvName = tab.TabPages[tab.SelectedIndex].Name;

    }

1 个答案:

答案 0 :(得分:0)

public static string Selected_dgvName;

private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Selected_dgvName = tabControl1.SelectedTab.Name;
        }

请检查您的标签名称,